From 3f20f6ec6691a0b6fad8e4cdfa5a9d047bd80fc3 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Tue, 29 Dec 2020 01:15:07 +0100 Subject: [PATCH 01/11] Generate all files in the build dir, don't touch source dir This makes it so that RCC files and jsdoc are both generated into the build directory. --- hifi_qt.py | 2 +- interface/CMakeLists.txt | 12 ++++++------ tools/jsdoc/CMakeLists.txt | 4 +++- tools/jsdoc/plugins/hifiJSONExport.js | 18 ++++++++++++++++-- tools/nitpick/CMakeLists.txt | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/hifi_qt.py b/hifi_qt.py index 078f80c38d..f832d5f940 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -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)) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a2a29ed4ba..8ada51561f 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -22,11 +22,11 @@ set(CUSTOM_INTERFACE_QRC_PATHS "") find_npm() 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") + 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) @@ -345,7 +345,7 @@ if (APPLE) "${RESOURCES_DEV_DIR}/scripts" # copy JSDoc files beside the executable COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${CMAKE_SOURCE_DIR}/tools/jsdoc/out" + "${CMAKE_CURRENT_BINARY_DIR}/tools/jsdoc" "${RESOURCES_DEV_DIR}/jsdoc" # copy the resources files beside the executable COMMAND "${CMAKE_COMMAND}" -E copy_if_different @@ -408,9 +408,9 @@ else() "${PROJECT_SOURCE_DIR}/resources/serverless/redirect.json" "${RESOURCES_DEV_DIR}/serverless/redirect.json" # copy JSDoc files beside the executable - COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${CMAKE_SOURCE_DIR}/tools/jsdoc/out" - "${INTERFACE_EXEC_DIR}/jsdoc" +# COMMAND "${CMAKE_COMMAND}" -E copy_directory +# "${CMAKE_CURRENT_BINARY_DIR}/tools/jsdoc/out" +# "${INTERFACE_EXEC_DIR}/jsdoc" ) # link target to external libraries diff --git a/tools/jsdoc/CMakeLists.txt b/tools/jsdoc/CMakeLists.txt index 1c4333983f..3c8245f0d9 100644 --- a/tools/jsdoc/CMakeLists.txt +++ b/tools/jsdoc/CMakeLists.txt @@ -5,9 +5,11 @@ 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) add_custom_command(TARGET ${TARGET_NAME} diff --git a/tools/jsdoc/plugins/hifiJSONExport.js b/tools/jsdoc/plugins/hifiJSONExport.js index e609b30ad5..057aaecda3 100644 --- a/tools/jsdoc/plugins/hifiJSONExport.js +++ b/tools/jsdoc/plugins/hifiJSONExport.js @@ -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 Date: Sun, 27 Jun 2021 16:35:32 +0200 Subject: [PATCH 02/11] Don't copy RCC, it's generated where it's needed --- interface/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 8ada51561f..31fab35df1 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -387,9 +387,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 From 7546be2e8a4a2662436461385333575fdcbd8b32 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 27 Jun 2021 16:35:54 +0200 Subject: [PATCH 03/11] Use qt5_add_binary_resources instead of custom command. Also move find_package for Qt to the top, so that it finds the rcc binary before it's needed --- interface/CMakeLists.txt | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 31fab35df1..8d15ccc22e 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -21,6 +21,14 @@ 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_BINARY_DIR}/tools/jsdoc/out/hifiJSDoc.json" "auto-complete/hifiJSDoc.json") endif () @@ -31,23 +39,12 @@ generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources 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() 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 +93,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}) From 70895df49e801e8eb11e6f03aecc5424fa1aa55d Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 27 Jun 2021 17:02:42 +0200 Subject: [PATCH 04/11] Generate nitpick resources with qt5_add_binary_resources Also, it appears there was a bug where nitpick depended on interface's resources rather than its own. --- tools/nitpick/CMakeLists.txt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tools/nitpick/CMakeLists.txt b/tools/nitpick/CMakeLists.txt index 19fe319e76..fa87a1c69c 100644 --- a/tools/nitpick/CMakeLists.txt +++ b/tools/nitpick/CMakeLists.txt @@ -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_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 From 60164dbf081b16739d98e51fe24e86cfcc93ecaf Mon Sep 17 00:00:00 2001 From: daleglass <51060919+daleglass@users.noreply.github.com> Date: Thu, 1 Jul 2021 18:56:11 +0200 Subject: [PATCH 05/11] Whitespace review fixes Co-authored-by: David Rowe --- tools/jsdoc/plugins/hifiJSONExport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jsdoc/plugins/hifiJSONExport.js b/tools/jsdoc/plugins/hifiJSONExport.js index 057aaecda3..148f83268b 100644 --- a/tools/jsdoc/plugins/hifiJSONExport.js +++ b/tools/jsdoc/plugins/hifiJSONExport.js @@ -5,7 +5,7 @@ exports.handlers = { var doclets = e.doclets.map(doclet => Object.assign({}, doclet)); var argv = process.argv; - for(var i=0; i Date: Fri, 2 Jul 2021 01:54:36 +0200 Subject: [PATCH 06/11] Fix copying jsdoc to interface Take the jsdoc from tools/jsdoc and copy it to interface. A subtle issue was found: It turns out that for cmake it matters what gets parsed first, especially if you rely on setting a variable in one project and reading it in another. This can result in things like builds that fail the first time, then work after re-running cmake. Generation of jsdoc and screenshare were moved above interface, because they're a dependency of it. --- CMakeLists.txt | 14 +++++++------- interface/CMakeLists.txt | 8 ++++---- tools/jsdoc/CMakeLists.txt | 2 ++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index facc1c999f..9031183d85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 8d15ccc22e..8067e800a5 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -335,7 +335,7 @@ if (APPLE) "${RESOURCES_DEV_DIR}/scripts" # copy JSDoc files beside the executable COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${CMAKE_CURRENT_BINARY_DIR}/tools/jsdoc" + "${JSDOC_OUTPUT_PATH}" "${RESOURCES_DEV_DIR}/jsdoc" # copy the resources files beside the executable COMMAND "${CMAKE_COMMAND}" -E copy_if_different @@ -395,9 +395,9 @@ else() "${PROJECT_SOURCE_DIR}/resources/serverless/redirect.json" "${RESOURCES_DEV_DIR}/serverless/redirect.json" # copy JSDoc files beside the executable -# COMMAND "${CMAKE_COMMAND}" -E copy_directory -# "${CMAKE_CURRENT_BINARY_DIR}/tools/jsdoc/out" -# "${INTERFACE_EXEC_DIR}/jsdoc" + COMMAND "${CMAKE_COMMAND}" -E copy_directory + "${JSDOC_OUTPUT_PATH}" + "${INTERFACE_EXEC_DIR}/jsdoc" ) # link target to external libraries diff --git a/tools/jsdoc/CMakeLists.txt b/tools/jsdoc/CMakeLists.txt index 3c8245f0d9..5a062b7ee9 100644 --- a/tools/jsdoc/CMakeLists.txt +++ b/tools/jsdoc/CMakeLists.txt @@ -12,6 +12,8 @@ file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/config.json JSDOC_CONFIG_PATH) 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} From 6a62dc10e6fd7f9452cd0306e79f3733c678ee01 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 3 Jul 2021 18:26:56 +0200 Subject: [PATCH 07/11] Fix resources and jsdoc dependencies --- interface/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 8067e800a5..b0b4ae0c5c 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -30,6 +30,7 @@ find_package( if (BUILD_TOOLS AND NPM_EXECUTABLE) + set(JSDOC_ENABLED 1) add_custom_qrc_path(CUSTOM_INTERFACE_QRC_PATHS "${CMAKE_BINARY_DIR}/tools/jsdoc/out/hifiJSDoc.json" "auto-complete/hifiJSDoc.json") endif () @@ -44,6 +45,10 @@ else () qt5_add_binary_resources(resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}") endif() +if (JSDOC_ENABLED) + add_dependencies(resources jsdoc) +endif() + list(APPEND GENERATE_QRC_DEPENDS ${RESOURCES_RCC}) # set a default root dir for each of our optional externals if it was not passed @@ -187,7 +192,7 @@ if (BUILD_TOOLS AND NPM_EXECUTABLE) add_dependencies(resources jsdoc) endif() -if (WIN32 OR APPLE) +if (NOT ANDROID) add_dependencies(${TARGET_NAME} resources) endif() From 96ad5e971b6940142ba5c040d1c905fd8cdba4b1 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 11 Jul 2021 19:22:20 +0200 Subject: [PATCH 08/11] Remove redundant cmake code --- interface/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index b0b4ae0c5c..804fd1ce85 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -186,12 +186,6 @@ 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 (NOT ANDROID) add_dependencies(${TARGET_NAME} resources) endif() From cf75200231df54f91be33803b38d30a5264085b0 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 11 Jul 2021 19:22:56 +0200 Subject: [PATCH 09/11] Have cmake be verbose about whether NPM has been detected --- tools/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 5de2f6fdf8..ce1e8c4d71 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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) From 276a0506bf6958e2dea575b6fc8274706ffdb34c Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 11 Jul 2021 19:26:34 +0200 Subject: [PATCH 10/11] Fix building interface without npm --- interface/CMakeLists.txt | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 804fd1ce85..10489eb57b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -19,8 +19,6 @@ endfunction() set(CUSTOM_INTERFACE_QRC_PATHS "") -find_npm() - find_package( Qt5 COMPONENTS Gui Widgets Multimedia Network Qml Quick Script Svg @@ -29,8 +27,8 @@ find_package( ) -if (BUILD_TOOLS AND NPM_EXECUTABLE) - set(JSDOC_ENABLED 1) +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 () @@ -45,7 +43,7 @@ else () qt5_add_binary_resources(resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}") endif() -if (JSDOC_ENABLED) +if (BUILD_TOOLS AND JSDOC_ENABLED) add_dependencies(resources jsdoc) endif() @@ -332,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 - "${JSDOC_OUTPUT_PATH}" - "${RESOURCES_DEV_DIR}/jsdoc" # copy the resources files beside the executable COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${RESOURCES_RCC}" @@ -367,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() @@ -393,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 "${JSDOC_OUTPUT_PATH}" - "${INTERFACE_EXEC_DIR}/jsdoc" - ) + "${INTERFACE_EXEC_DIR}/jsdoc") + endif() # link target to external libraries if (WIN32) From 32c3725b5d455918e5243bcafe1b56356319d794 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 17 Jul 2021 19:34:26 +0200 Subject: [PATCH 11/11] Define _USE_MATH_DEFINES everywhere that uses math constants On Win32, things are failing to build with messages like: RenderableEntityItem.cpp(674,51): error C2065: 'M_PI': undeclared identifier This is because as per Microsoft documentation, _USE_MATH_DEFINES is needed to obtain constants like M_PI: https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=msvc-160 It seems this worked previously due to some quirk of CMake, but stopped working after some reordering. This change makes this definition explicit where it is needed. --- libraries/animation/CMakeLists.txt | 4 ++++ libraries/entities-renderer/CMakeLists.txt | 3 +++ libraries/entities/CMakeLists.txt | 4 ++++ libraries/image/CMakeLists.txt | 4 ++++ libraries/render-utils/CMakeLists.txt | 3 +++ libraries/shared/CMakeLists.txt | 1 + 6 files changed, 19 insertions(+) diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index d962d9e222..2e811969ec 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -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() diff --git a/libraries/entities-renderer/CMakeLists.txt b/libraries/entities-renderer/CMakeLists.txt index 5f40c8d5fe..67f34f4831 100644 --- a/libraries/entities-renderer/CMakeLists.txt +++ b/libraries/entities-renderer/CMakeLists.txt @@ -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() diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index bddd4b5e67..b6ed62c15a 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -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() diff --git a/libraries/image/CMakeLists.txt b/libraries/image/CMakeLists.txt index 62f48f66e2..8c72bc7e72 100644 --- a/libraries/image/CMakeLists.txt +++ b/libraries/image/CMakeLists.txt @@ -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() diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index 4c444bcd15..904e7ea94c 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -16,3 +16,6 @@ if (NOT ANDROID) target_nsight() endif () +if (WIN32) + add_compile_definitions(_USE_MATH_DEFINES) +endif() diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 57904be586..59fb4d81ab 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -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)