Merge pull request #943 from daleglass/cmake-build-in-build-dir

Cmake: build in build dir
This commit is contained in:
Dale Glass 2021-07-22 23:26:21 +02:00 committed by GitHub
commit 567ff291fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 90 additions and 65 deletions

View file

@ -337,6 +337,13 @@ if (BUILD_GPU_FRAME_PLAYER_ONLY)
add_subdirectory(tools/gpu-frame-player)
else()
if (SCREENSHARE)
add_subdirectory(screenshare)
endif()
# BUILD_TOOLS option will be handled inside the tools's CMakeLists.txt because 'scribe' tool is required for build anyway
add_subdirectory(tools)
# add subdirectories for all targets
if (BUILD_SERVER)
add_subdirectory(assignment-client)
@ -363,13 +370,6 @@ if (BUILD_CLIENT OR BUILD_SERVER)
add_subdirectory(server-console)
endif()
if (SCREENSHARE)
add_subdirectory(screenshare)
endif()
# BUILD_TOOLS option will be handled inside the tools's CMakeLists.txt because 'scribe' tool is required for build anyway
add_subdirectory(tools)
endif()
if (BUILD_TESTS)

View file

@ -196,7 +196,7 @@ endif()
print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder")
print("")
print("Alternatively, you can try building against the system Qt by setting the VIRCADIA_USE_SYSTEM_QT environment variable.")
print("You'll need to install the development packages, and to have Qt 5.15.0 or newer. ")
print("You'll need to install the development packages, and to have Qt 5.15.0 or later.")
def writeConfig(self):
print("Writing cmake config to {}".format(self.configFilePath))

View file

@ -19,35 +19,35 @@ endfunction()
set(CUSTOM_INTERFACE_QRC_PATHS "")
find_npm()
find_package(
Qt5 COMPONENTS
Gui Widgets Multimedia Network Qml Quick Script Svg
${PLATFORM_QT_COMPONENTS}
WebChannel WebSockets
)
if (BUILD_TOOLS AND NPM_EXECUTABLE)
add_custom_qrc_path(CUSTOM_INTERFACE_QRC_PATHS "${CMAKE_SOURCE_DIR}/tools/jsdoc/out/hifiJSDoc.json" "auto-complete/hifiJSDoc.json")
if (BUILD_TOOLS AND JSDOC_ENABLED)
message(STATUS "JSDoc enabled, depending on jsdoc")
add_custom_qrc_path(CUSTOM_INTERFACE_QRC_PATHS "${CMAKE_BINARY_DIR}/tools/jsdoc/out/hifiJSDoc.json" "auto-complete/hifiJSDoc.json")
endif ()
set(RESOURCES_QRC ${CMAKE_CURRENT_BINARY_DIR}/resources.qrc)
set(RESOURCES_RCC ${CMAKE_CURRENT_SOURCE_DIR}/compiledResources/resources.rcc)
set(RESOURCES_RCC ${CMAKE_CURRENT_BINARY_DIR}/resources.rcc)
generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources CUSTOM_PATHS ${CUSTOM_INTERFACE_QRC_PATHS} GLOBS *)
if (ANDROID)
# on Android, don't compress the rcc binary
add_custom_command(
OUTPUT ${RESOURCES_RCC}
DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS}
COMMAND "${RCC_BINARY}"
ARGS ${RESOURCES_QRC} -no-compress -binary -o ${RESOURCES_RCC}
)
qt5_add_binary_resources(resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}" OPTIONS -no-compress)
else ()
add_custom_command(
OUTPUT ${RESOURCES_RCC}
DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS}
COMMAND "${RCC_BINARY}"
ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC}
)
qt5_add_binary_resources(resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}")
endif()
if (BUILD_TOOLS AND JSDOC_ENABLED)
add_dependencies(resources jsdoc)
endif()
list(APPEND GENERATE_QRC_DEPENDS ${RESOURCES_RCC})
add_custom_target(resources ALL DEPENDS ${GENERATE_QRC_DEPENDS})
# set a default root dir for each of our optional externals if it was not passed
set(OPTIONAL_EXTERNALS "LeapMotion")
@ -96,13 +96,6 @@ else ()
list(REMOVE_ITEM INTERFACE_SRCS ${SPEECHRECOGNIZER_CPP})
endif ()
find_package(
Qt5 COMPONENTS
Gui Widgets Multimedia Network Qml Quick Script Svg
${PLATFORM_QT_COMPONENTS}
WebChannel WebSockets
)
# grab the ui files in resources/ui
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
source_group("UI Files" FILES ${QT_UI_FILES})
@ -191,13 +184,7 @@ else ()
add_executable(${TARGET_NAME} ${INTERFACE_SRCS} ${QM})
endif ()
if (BUILD_TOOLS AND NPM_EXECUTABLE)
# require JSDoc to be build before interface is deployed
add_dependencies(resources jsdoc)
endif()
if (WIN32 OR APPLE)
if (NOT ANDROID)
add_dependencies(${TARGET_NAME} resources)
endif()
@ -343,10 +330,6 @@ if (APPLE)
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_SOURCE_DIR}/scripts"
"${RESOURCES_DEV_DIR}/scripts"
# copy JSDoc files beside the executable
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out"
"${RESOURCES_DEV_DIR}/jsdoc"
# copy the resources files beside the executable
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${RESOURCES_RCC}"
@ -378,6 +361,13 @@ if (APPLE)
)
endif()
if (JSDOC_ENABLED)
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
# copy JSDoc files beside the executable
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${JSDOC_OUTPUT_PATH}"
"${RESOURCES_DEV_DIR}/jsdoc")
endif()
# call the fixup_interface macro to add required bundling commands for installation
fixup_interface()
@ -387,9 +377,6 @@ else()
# copy the resources files beside the executable
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${RESOURCES_RCC}"
"${INTERFACE_EXEC_DIR}"
# FIXME, the edit script code loads HTML from the scripts folder
# which in turn relies on CSS that refers to the fonts. In theory
# we should be able to modify the CSS to reference the QRC path to
@ -407,11 +394,15 @@ else()
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/resources/serverless/redirect.json"
"${RESOURCES_DEV_DIR}/serverless/redirect.json"
)
if (JSDOC_ENABLED)
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
# copy JSDoc files beside the executable
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out"
"${INTERFACE_EXEC_DIR}/jsdoc"
)
"${JSDOC_OUTPUT_PATH}"
"${INTERFACE_EXEC_DIR}/jsdoc")
endif()
# link target to external libraries
if (WIN32)

View file

@ -7,3 +7,7 @@ include_hifi_library_headers(hfm)
include_hifi_library_headers(image)
target_nsight()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -19,3 +19,6 @@ include_hifi_library_headers(graphics-scripting) # for Forward.h
target_bullet()
target_polyvox()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -9,3 +9,7 @@ include_hifi_library_headers(ktx)
include_hifi_library_headers(material-networking)
include_hifi_library_headers(procedural)
link_hifi_libraries(shared shaders networking octree avatars graphics model-networking)
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -11,3 +11,7 @@ if (UNIX AND NOT APPLE)
find_package(Threads REQUIRED)
target_link_libraries(image Threads::Threads)
endif()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -16,3 +16,6 @@ if (NOT ANDROID)
target_nsight()
endif ()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -7,6 +7,7 @@ setup_hifi_library(Gui Network Script)
if (WIN32)
target_link_libraries(${TARGET_NAME} Wbemuuid.lib)
add_compile_definitions(_USE_MATH_DEFINES)
endif()
if (ANDROID)

View file

@ -1,9 +1,13 @@
# add the tool directories
message(STATUS "Checking for npm")
find_npm()
if (NPM_EXECUTABLE)
add_subdirectory(jsdoc)
set_target_properties(jsdoc PROPERTIES FOLDER "Tools")
message(STATUS "Checking for npm - found ${NPM_EXECUTABLE}, will build jsdoc")
add_subdirectory(jsdoc)
set_target_properties(jsdoc PROPERTIES FOLDER "Tools")
else()
message(NOTICE "Checking for npm - not found, jsdoc won't be genereated. Tab completion in the js console won't work!")
endif()
function(check_test name)

View file

@ -5,11 +5,15 @@ add_custom_target(${TARGET_NAME})
find_npm()
set(JSDOC_WORKING_DIR ${CMAKE_SOURCE_DIR}/tools/jsdoc)
set(JSDOC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/node_modules/.bin/jsdoc JSDOC_PATH)
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/config.json JSDOC_CONFIG_PATH)
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/out OUTPUT_DIR)
file(TO_NATIVE_PATH ${JSDOC_OUTPUT_DIR}/out OUTPUT_DIR)
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/root.js NATIVE_JSDOC_WORKING_DIR)
set(JSDOC_OUTPUT_PATH ${OUTPUT_DIR} CACHE INTERNAL "${PROJECT_NAME}: JSDoc output directory")
add_custom_command(TARGET ${TARGET_NAME}
COMMAND ${NPM_EXECUTABLE} --no-progress install && ${JSDOC_PATH} ${NATIVE_JSDOC_WORKING_DIR} -c ${JSDOC_CONFIG_PATH} -d ${OUTPUT_DIR}
WORKING_DIRECTORY ${JSDOC_WORKING_DIR}

View file

@ -1,8 +1,22 @@
exports.handlers = {
processingComplete: function(e) {
const pathTools = require('path');
var outputFolder = pathTools.join(__dirname, '../out');
var outputFolder;
var doclets = e.doclets.map(doclet => Object.assign({}, doclet));
var argv = process.argv;
for (var i = 0; i < argv.length; i++) {
if (argv[i] === '-d') {
outputFolder = argv[i+1];
break;
}
}
if (!outputFolder) {
console.log("Output folder not found, specify it with -d");
process.exit(1);
}
const fs = require('fs');
if (!fs.existsSync(outputFolder)) {
fs.mkdirSync(outputFolder);
@ -13,7 +27,7 @@ exports.handlers = {
return console.log(err);
}
console.log("The Vircadia JSDoc JSON was saved!");
console.log("The Vircadia JSDoc JSON was saved into " + outputFolder + "!");
});
}
};

View file

@ -4,24 +4,19 @@ project(${TARGET_NAME})
set(CUSTOM_NITPICK_QRC_PATHS "")
find_npm()
find_package(Qt5 COMPONENTS Widgets)
set(RESOURCES_QRC ${CMAKE_CURRENT_BINARY_DIR}/resources.qrc)
set(RESOURCES_RCC ${CMAKE_CURRENT_SOURCE_DIR}/compiledResources/resources.rcc)
set(RESOURCES_RCC ${CMAKE_CURRENT_BINARY_DIR}/resources.rcc)
generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources CUSTOM_PATHS ${CUSTOM_NITPICK_QRC_PATHS} GLOBS *)
add_custom_command(
OUTPUT ${RESOURCES_RCC}
DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS}
COMMAND "${RCC_BINARY}"
ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC}
)
qt5_add_binary_resources(nitpick_resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}" OPTIONS -no-compress)
# grab the implementation and header files from src dirs
file(GLOB_RECURSE NITPICK_SRCS "src/*.cpp" "src/*.h")
GroupSources("src")
list(APPEND NITPICK_SRCS ${RESOURCES_RCC})
find_package(Qt5 COMPONENTS Widgets)
# grab the ui files in ui
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
@ -83,9 +78,7 @@ else ()
add_executable(${TARGET_NAME} ${NITPICK_SRCS} ${QM})
endif ()
if (NOT UNIX)
add_dependencies(${TARGET_NAME} resources)
endif()
add_dependencies(${TARGET_NAME} nitpick_resources)
# disable /OPT:REF and /OPT:ICF for the Debug builds
# This will prevent the following linker warnings