diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index ff4ae3b4f3..6da3755ea4 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -13,14 +13,28 @@ macro(SETUP_HIFI_LIBRARY TARGET) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) - set(LIB_SRCS ${LIB_SRCS} ${WRAPPED_SRCS}) + set(LIB_SRCS ${LIB_SRCS}) - # create a library and set the property so it can be referenced later - add_library(${TARGET} ${LIB_SRCS} ${ARGN}) + # create a library and set the property so it can be referenced later + add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) - find_package(Qt5Core REQUIRED) - qt5_use_modules(${TARGET} Core) - - target_link_libraries(${TARGET} ${QT_LIBRARIES}) + set(QT_MODULES_TO_LINK ${ARGN}) + list(APPEND QT_MODULES_TO_LINK Core) + + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + + foreach(QT_MODULE ${QT_MODULES_TO_LINK}) + # link this Qt module to ourselves + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + + get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) + + # add the actual path to the Qt module to a QT_LIBRARIES variable + list(APPEND QT_LIBRARIES ${QT_LIBRARY_LOCATION}) + endforeach() + + if (QT_LIBRARIES) + set_target_properties(${TARGET} PROPERTIES DEPENDENCY_LIBRARIES "${QT_LIBRARIES}") + endif () endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 26b98ca17f..9c419d9369 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,12 +1,6 @@ set(TARGET_NAME animation) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared fbx) \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index a066c3a73b..354a3772dd 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME audio) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} networking shared) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} networking shared) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 9d7d452696..d05faf3b27 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,15 +1,9 @@ set(TARGET_NAME avatars) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) -include_hifi_library_headers(fbx) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +include_hifi_library_headers(fbx) \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index 5b815625ba..c299aa654d 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,17 +1,4 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME embedded-webserver) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) -setup_hifi_library(${TARGET_NAME}) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 12047498c2..e9658de4a2 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET_NAME fbx) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index b0e8f14374..20b448725f 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -2,16 +2,10 @@ set(TARGET_NAME metavoxels) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Scripts Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +include_glm(${TARGET_NAME} "${ROOT_DIR}") \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 45d0ab0b70..c0610b0501 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME models) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index fe8cd003a3..fb9f07b81a 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,12 +1,6 @@ set(TARGET_NAME networking) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) -link_hifi_libraries(${TARGET_NAME} shared) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared) \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index ca4e5caafd..340b2393e6 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET_NAME octree) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -15,4 +16,4 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 8efeedc9d9..2f523b22f7 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,15 +1,9 @@ set(TARGET_NAME particles) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Gui Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) -include_hifi_library_headers(script-engine) - -find_package(Qt5 COMPONENTS Gui Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +include_hifi_library_headers(script-engine) \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 0b79530210..cce7d8d07b 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME script-engine) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) - -find_package(Qt5 COMPONENTS Gui Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index b8e34739b8..9cc1b968dc 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,9 +1,4 @@ set(TARGET_NAME shared) -setup_hifi_library(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network Widgets) - -# bubble up the libraries we are dependent on and link them to ourselves -list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Widgets) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 739fe3ef62..7f200523de 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,6 +1,7 @@ set(TARGET_NAME voxels) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Widgets Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -8,7 +9,8 @@ link_hifi_libraries(${TARGET_NAME} shared octree networking) # link ZLIB find_package(ZLIB) -find_package(Qt5 COMPONENTS Widgets Script) - include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) + +get_target_property(LINKED_LIBRARIES ${TARGET_NAME} DEPENDENCY_LIBRARIES) +list(APPEND DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES) \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 51b42780c8..34d053b008 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -6,4 +6,4 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) +link_hifi_libraries(${TARGET_NAME} shared audio networking) \ No newline at end of file diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c9c0690cc7..32a82627a3 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,4 +1,3 @@ - # add the tool directories add_subdirectory(bitstream2json) add_subdirectory(json2bitstream) diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 582c5e3bfd..467d03d241 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,7 +1,2 @@ set(TARGET_NAME mtc) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file