From 4637821c30b0e303028ecf086bf694ac298d502d Mon Sep 17 00:00:00 2001 From: Edgar Velazquez-Armendariz Date: Sat, 2 Feb 2013 09:26:01 -0500 Subject: [PATCH] Link the executables only agains libcore and librender by default in CMake --- data/cmake/MitsubaUtil.cmake | 27 ++++++++++++++++++++------- src/converter/CMakeLists.txt | 2 +- src/mtsgui/CMakeLists.txt | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/data/cmake/MitsubaUtil.cmake b/data/cmake/MitsubaUtil.cmake index c55b38c4..473be190 100644 --- a/data/cmake/MitsubaUtil.cmake +++ b/data/cmake/MitsubaUtil.cmake @@ -310,15 +310,15 @@ macro (add_mts_plugin _plugin_name) add_library (${_plugin_name} MODULE ${_plugin_srcs}) endif () - set(core_libraries "mitsuba-core" "mitsuba-render") + set(_plugin_core_libraries "mitsuba-core" "mitsuba-render") if (_plugin_MTS_HW) - list(APPEND core_libraries "mitsuba-hw") + list(APPEND _plugin_core_libraries "mitsuba-hw") endif() if (_plugin_MTS_BIDIR) - list(APPEND core_libraries "mitsuba-bidir") + list(APPEND _plugin_core_libraries "mitsuba-bidir") endif() target_link_libraries (${_plugin_name} - ${core_libraries} ${_plugin_LINK_LIBRARIES}) + ${_plugin_core_libraries} ${_plugin_LINK_LIBRARIES}) set_target_properties (${_plugin_name} PROPERTIES PREFIX "") if (APPLE) @@ -369,6 +369,7 @@ endif() # [RES_ICON filename] # [RES_DESCRIPTION "Description string"] # [NO_INSTALL] +# [MTS_HW] [MTS_BIDIR] # [NO_MTS_PCH | PCH pch_header] ) # # The executable name is taken from the first argument. The target gets @@ -377,6 +378,11 @@ endif() # (for example, libpng) may be specified after the optionl LINK_LIBRARIES # keyword. # +# By default the executables are linked against mitsuba-core and mitsuba-render. +# When MTS_HW is set, the executable will be linked against with mitsuba-hw. +# When MTS_BIDIR is specified, the executable will also be linked against +# mitsuba-bidir. +# # The optional keyword WIN32, if presents, gets passed to add_executable(...) # to produce a Windows executable using winmain, thus it won't have a # console. The NO_INSTALL keyword causes the target not to be installed. @@ -390,7 +396,7 @@ endif() # builds; other platforms simply ignore this value as with RES_ICON. # macro (add_mts_exe _exe_name) - CMAKE_PARSE_ARGUMENTS(_exe "WIN32;NO_INSTALL;NO_MTS_PCH" + CMAKE_PARSE_ARGUMENTS(_exe "WIN32;NO_INSTALL;MTS_HW;MTS_BIDIR;NO_MTS_PCH" "PCH;RES_ICON;RES_DESCRIPTION" "LINK_LIBRARIES" ${ARGN}) set (_exe_srcs ${_exe_UNPARSED_ARGUMENTS}) if (_exe_WIN32) @@ -427,8 +433,15 @@ macro (add_mts_exe _exe_name) else () add_executable (${_exe_name} ${_exe_TYPE} ${_exe_srcs}) endif () - target_link_libraries (${_exe_name} - ${MTS_CORELIBS} ${_exe_LINK_LIBRARIES}) + + set(_exe_core_libraries "mitsuba-core" "mitsuba-render") + if (_exe_MTS_HW) + list(APPEND _exe_core_libraries "mitsuba-hw") + endif() + if (_exe_MTS_BIDIR) + list(APPEND _exe_core_libraries "mitsuba-bidir") + endif() + target_link_libraries (${_exe_name} ${_exe_core_libraries} ${_exe_LINK_LIBRARIES}) if (WIN32) set_target_properties (${_exe_name} PROPERTIES VERSION "${MTS_VERSION}") endif() diff --git a/src/converter/CMakeLists.txt b/src/converter/CMakeLists.txt index 0bfabe44..08ca9749 100644 --- a/src/converter/CMakeLists.txt +++ b/src/converter/CMakeLists.txt @@ -25,5 +25,5 @@ target_link_libraries(mtsconverter_lib ${COLLADA_LIBRARIES} ${XERCES_LIBRARIES} ${OPENGL_glu_LIBRARY}) add_mts_exe(mtsimport mtsimport.cpp ${SRCS} - ${MTS_DARWIN_STUB} ${MTS_WINDOWS_STUB} LINK_LIBRARIES mtsconverter_lib + ${MTS_DARWIN_STUB} ${MTS_WINDOWS_STUB} MTS_HW LINK_LIBRARIES mtsconverter_lib RES_DESCRIPTION "Mitsuba COLLADA 1.4 & Wavefront OBJ importer") diff --git a/src/mtsgui/CMakeLists.txt b/src/mtsgui/CMakeLists.txt index 15e9d0eb..5701cdbc 100644 --- a/src/mtsgui/CMakeLists.txt +++ b/src/mtsgui/CMakeLists.txt @@ -169,7 +169,7 @@ add_mts_exe(mtsgui ${MTS_EXE_TYPE} ${SRCS} ${HDRS} PCH "${CMAKE_CURRENT_SOURCE_DIR}/pch/mtsgui_precompiled.hpp" RES_ICON "${PROJECT_SOURCE_DIR}/data/windows/mitsuba.ico" RES_DESCRIPTION "Mitsuba interactive Qt-based frontend" - LINK_LIBRARIES ${LIBS}) + MTS_HW LINK_LIBRARIES ${LIBS}) # Custom targets to copy the bundle files and the PreviewSettings objects