diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 54e252c80..ebd9a6177 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -27,17 +27,29 @@ endmacro(P21_TESTS sfile) # create p21read_sdai_*, lazy_sdai_*, any exes listed in SC_SDAI_ADDITIONAL_EXES_SRCS macro(SCHEMA_EXES) RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT) - SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc;${RELATIVE_PATH_COMPONENT}/src/test/p21read/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE) + if(BUILD_SHARED_LIBS) + SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc;${RELATIVE_PATH_COMPONENT}/src/test/p21read/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE) + elseif(BUILD_STATIC_LIBS) + SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc;${RELATIVE_PATH_COMPONENT}/src/test/p21read/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME}-static stepeditor-static stepcore-static stepdai-static steputils-static TESTABLE) + endif() if(NOT WIN32) - SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc;${RELATIVE_PATH_COMPONENT}/src/cllazyfile/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils TESTABLE) + if(BUILD_SHARED_LIBS) + SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc;${RELATIVE_PATH_COMPONENT}/src/cllazyfile/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils TESTABLE) + elseif(BUILD_STATIC_LIBS) + SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc;${RELATIVE_PATH_COMPONENT}/src/cllazyfile/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME}-static steplazyfile-static stepeditor-static stepcore-static stepdai-static steputils-static TESTABLE) + endif() endif(NOT WIN32) #add user-defined executables foreach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS}) get_filename_component(name ${src} NAME_WE) get_filename_component(path ${src} ABSOLUTE) - SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE) + if(BUILD_SHARED_LIBS) + SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE) + elseif(BUILD_STATIC_LIBS) + SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME}-static stepcore-static stepdai-static stepeditor-static steputils-static TESTABLE) #set_target_properties(${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}") + endif() endforeach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS}) ENDMACRO(SCHEMA_EXES) @@ -111,7 +123,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static) + SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepcore-static stepdai-static stepeditor-static steputils-static) add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME}) target_compile_definitions("${PROJECT_NAME}-static" PRIVATE SC_STATIC) if(MSVC) diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index cb2d11dd6..8218fad6e 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -10,15 +10,20 @@ macro(SC_ADDEXEC execname) add_executable(${execname} ${${_arg_prefix}_SOURCES}) + if(BUILD_STATIC_LIBS) + target_compile_definitions(${execname} PRIVATE SC_STATIC) + endif() + if(DEFINED "${_arg_prefix}_LINK_LIBRARIES") foreach(_lib ${${_arg_prefix}_LINK_LIBRARIES}) if($CACHE{SC_STATIC_UTILS}) - if(NOT $ STREQUAL "STATIC_LIBRARY") + get_property(_lib_type TARGET ${_lib} PROPERTY TYPE) + if(NOT _lib_type STREQUAL "STATIC_LIBRARY") message(SEND_ERROR "SC_ADDEXEC usage error - expected STATIC LINK_LIBRARIES targets (${_lib})") endif() endif() - target_link_libraries(${execname} ${_lib}) endforeach() + target_link_libraries(${execname} PRIVATE ${${_arg_prefix}_LINK_LIBRARIES}) endif() if(NOT ${_arg_prefix}_NO_INSTALL AND NOT ${_arg_prefix}_TESTABLE) @@ -37,7 +42,7 @@ endmacro() macro(SC_ADDLIB _addlib_target) set(_addlib_opts SHARED STATIC NO_INSTALL TESTABLE) set(_addlib_multikw SOURCES LINK_LIBRARIES) - string(TOUPPER "SC_ADDLIB_${libname}_ARG" _arg_prefix) + string(TOUPPER "SC_ADDLIB_${_addlib_target}_ARG" _arg_prefix) cmake_parse_arguments(${_arg_prefix} "${_addlib_opts}" "" "${_addlib_multikw}" ${ARGN}) if(NOT DEFINED ${_arg_prefix}_SOURCES) @@ -64,20 +69,20 @@ macro(SC_ADDLIB _addlib_target) if(DEFINED ${_arg_prefix}_LINK_LIBRARIES) foreach(_lib ${${_arg_prefix}_LINK_LIBRARIES}) if(${_arg_prefix}_STATIC AND TARGET ${_lib}) - get_property(_libtype TARGET ${_lib} PROPERTY TYPE) - if(NOT ${_libtype} STREQUAL "STATIC_LIBRARY") - message(SEND_ERROR "SC_ADDLIB usage error - expected (static) LINK_LIBRARIES targets (${_lib})") + get_property(_libtype TARGET ${_lib} PROPERTY TYPE) + if(NOT ${_libtype} STREQUAL "STATIC_LIBRARY") + message(SEND_ERROR "SC_ADDLIB usage error - expected (static) LINK_LIBRARIES targets (${_lib})") endif() endif() - target_link_libraries(${_addlib_target} ${_lib}) endforeach() + target_link_libraries(${_addlib_target} ${_lib}) endif() if(NOT ${_arg_prefix}_NO_INSTALL AND NOT ${_arg_prefix}_TESTABLE) install(TARGETS ${_addlib_target} RUNTIME DESTINATION ${BIN_DIR} LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR} ) endif() endmacro() diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 2b306068e..f0a842841 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -21,7 +21,7 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(stepeditor-static STATIC SOURCES ${EDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static) + SC_ADDLIB(stepeditor-static STATIC SOURCES ${EDITOR_SRCS} LINK_LIBRARIES steputils-static stepdai-static stepcore-static) endif() # Local Variables: diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index c56e8dbbc..83b2d7137 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -13,22 +13,27 @@ include_directories( ${CMAKE_SOURCE_DIR}/include/stepcode ) -set(_libdeps stepcore stepdai steputils stepeditor) + if(BUILD_SHARED_LIBS) + set(_libdeps stepcore stepdai steputils stepeditor) SC_ADDLIB(steplazyfile SHARED SOURCES ${LAZY_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) endif() + SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile stepeditor ${_libdeps} NO_INSTALL) + target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) endif() if(BUILD_STATIC_LIBS) set(_libdeps stepcore-static stepdai-static steputils-static stepeditor-static) SC_ADDLIB(steplazyfile-static STATIC SOURCES ${LAZY_SRCS} LINK_LIBRARIES ${_libdeps}) + if(NOT BUILD_SHARED_LIBS) + SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile-static stepeditor-static ${_libdeps} NO_INSTALL) + target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) + endif() endif() -SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) -target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) # Local Variables: # tab-width: 8 diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index e31f8ad8e..25e96a8d9 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -66,9 +66,8 @@ include_directories( ${CMAKE_SOURCE_DIR}/include/stepcode ) -set(_libdeps steputils stepdai) - if(BUILD_SHARED_LIBS) + set(_libdeps steputils stepdai) SC_ADDLIB(stepcore SHARED SOURCES ${CORE_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) @@ -76,7 +75,8 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(stepcore-static STATIC SOURCES ${CORE_SRCS} LINK_LIBRARIES $-static) + set(_libdeps steputils-static stepdai-static) + SC_ADDLIB(stepcore-static STATIC SOURCES ${CORE_SRCS} LINK_LIBRARIES ${_libdeps}) endif() if(SC_ENABLE_TESTING) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index e5c0dfe04..b2ce1ae10 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -139,6 +139,7 @@ if(BUILD_SHARED_LIBS OR NOT BUILD_STATIC_LIBS) target_link_libraries(check-express express) else() target_link_libraries(check-express express-static) + target_compile_definitions(check-express PRIVATE SC_STATIC) endif() install(TARGETS check-express RUNTIME DESTINATION ${BIN_DIR}