From fb8403a06400bce6aeb85978a3d473dadd47aaca Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 20 Jan 2018 00:55:43 +0100 Subject: [PATCH] CMake: Only link executables to enabled libraries --- build/cmake/functions.cmake | 2 +- build/cmake/tests/base/CMakeLists.txt | 3 +++ build/cmake/tests/drawing/CMakeLists.txt | 3 +++ build/cmake/tests/gui/CMakeLists.txt | 24 +++++++++++++++++++++++- build/cmake/utils/CMakeLists.txt | 5 ++++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 75e0f1f2ba..c92abdd9e4 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -701,7 +701,7 @@ function(wx_add_test name) endif() add_executable(${name} ${test_src}) target_include_directories(${name} PRIVATE "${wxSOURCE_DIR}/tests" "${wxSOURCE_DIR}/3rdparty/catch/include") - wx_exe_link_libraries(${name} base net) + wx_exe_link_libraries(${name} base) if(wxBUILD_SHARED) target_compile_definitions(${name} PRIVATE WXUSINGDLL) endif() diff --git a/build/cmake/tests/base/CMakeLists.txt b/build/cmake/tests/base/CMakeLists.txt index 2dc9f50c97..25f614e885 100644 --- a/build/cmake/tests/base/CMakeLists.txt +++ b/build/cmake/tests/base/CMakeLists.txt @@ -99,6 +99,9 @@ endif() wx_add_test(test_base ${TEST_SRC}) target_compile_definitions(test_base PRIVATE wxUSE_GUI=0 wxUSE_BASE=1) +if(wxUSE_SOCKETS) + wx_exe_link_libraries(test_base net) +endif() if(wxUSE_XML) wx_exe_link_libraries(test_base xml) endif() diff --git a/build/cmake/tests/drawing/CMakeLists.txt b/build/cmake/tests/drawing/CMakeLists.txt index 599bbfa91e..f9dbc7c0cf 100644 --- a/build/cmake/tests/drawing/CMakeLists.txt +++ b/build/cmake/tests/drawing/CMakeLists.txt @@ -22,6 +22,9 @@ set(TEST_DRAWING_SRC drawing/fonttest.cpp ) wx_add_test(test_drawing ${TEST_DRAWING_SRC}) +if(wxUSE_SOCKETS) + wx_exe_link_libraries(test_drawing net) +endif() wx_exe_link_libraries(test_drawing core) wx_test_enable_precomp(test_drawing) diff --git a/build/cmake/tests/gui/CMakeLists.txt b/build/cmake/tests/gui/CMakeLists.txt index fe32199597..9394ce3710 100644 --- a/build/cmake/tests/gui/CMakeLists.txt +++ b/build/cmake/tests/gui/CMakeLists.txt @@ -107,5 +107,27 @@ set(TEST_GUI_SRC xml/xrctest.cpp ) wx_add_test(test_gui ${TEST_GUI_SRC}) -wx_exe_link_libraries(test_gui core richtext media xrc xml adv html net webview) +wx_exe_link_libraries(test_gui core) +if(wxUSE_RICHTEXT) + wx_exe_link_libraries(test_gui richtext) +endif() +if(wxUSE_MEDIACTRL) + wx_exe_link_libraries(test_gui media) +endif() +if(wxUSE_XRC) + wx_exe_link_libraries(test_gui xrc) +endif() +if(wxUSE_XML) + wx_exe_link_libraries(test_gui xml) +endif() +wx_exe_link_libraries(test_gui adv) +if(wxUSE_HTML) + wx_exe_link_libraries(test_gui html) +endif() +if(wxUSE_SOCKETS) + wx_exe_link_libraries(test_gui net) +endif() +if(wxUSE_WEBVIEW) + wx_exe_link_libraries(test_gui webview) +endif() wx_test_enable_precomp(test_gui) diff --git a/build/cmake/utils/CMakeLists.txt b/build/cmake/utils/CMakeLists.txt index bbb604e60e..bf29f72156 100644 --- a/build/cmake/utils/CMakeLists.txt +++ b/build/cmake/utils/CMakeLists.txt @@ -13,7 +13,10 @@ if(wxUSE_XRC) if(wxBUILD_SHARED) target_compile_definitions(wxrc PRIVATE WXUSINGDLL) endif() - wx_exe_link_libraries(wxrc xml base) + if(wxUSE_XML) + wx_exe_link_libraries(wxrc xml) + endif() + wx_exe_link_libraries(wxrc base) # TODO: install set_target_properties(wxrc PROPERTIES FOLDER "Utilities") endif()