From 46076203f23e1f9a3891ab4802b8d5fb31f83c85 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 14 Nov 2024 21:58:21 +0000 Subject: [PATCH] cmake: remove intermediate object libraries this is so static and shared code can be compiled separately by MSVC --- cmake/Templates.cmake | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/cmake/Templates.cmake b/cmake/Templates.cmake index d8fa78c..81ee7e3 100644 --- a/cmake/Templates.cmake +++ b/cmake/Templates.cmake @@ -11,38 +11,31 @@ function(add_bluelib_module) set(root_header include/blue/${module_name}.h) file(GLOB headers include/blue/${module_name}/*.h) - add_library(blue-${module_name}-obj OBJECT ${sources} ${sys_sources} ${root_header} ${headers}) - - set_target_properties(blue-${module_name}-obj - PROPERTIES POSITION_INDEPENDENT_CODE ON) - string(REPLACE "-" "_" module_preproc_token ${module_name}) string(TOUPPER ${module_preproc_token} module_preproc_token) set(module_preproc_token BLUELIB_${module_preproc_token}) - target_include_directories(blue-${module_name}-obj PUBLIC include/) - target_compile_definitions(blue-${module_name}-obj PUBLIC ${module_preproc_token} BLUELIB_EXPORT=1) - - foreach (dep ${arg_DEPENDENCIES}) - target_link_libraries(blue-${module_name}-obj blue-${dep}-obj) - endforeach (dep) - message(STATUS "Building module ${module_name} (shared)") - add_library(blue-${module_name} SHARED $) + add_library(blue-${module_name} SHARED ${sources} ${sys_sources} ${root_header} ${headers}) message(STATUS "Building module ${module_name} (static)") - add_library(blue-${module_name}-s STATIC $) + add_library(blue-${module_name}-s STATIC ${sources} ${sys_sources} ${root_header} ${headers}) target_include_directories(blue-${module_name} PUBLIC include/) target_include_directories(blue-${module_name}-s PUBLIC include/) + target_compile_definitions(blue-${module_name} PUBLIC ${module_preproc_token} BLUELIB_EXPORT=1) + target_compile_definitions(blue-${module_name}-s PUBLIC ${module_preproc_token} BLUELIB_EXPORT=1 BLUELIB_STATIC=1) + + set_target_properties(blue-${module_name} + PROPERTIES POSITION_INDEPENDENT_CODE ON) + foreach (dep ${arg_DEPENDENCIES}) target_link_libraries(blue-${module_name} blue-${dep}) target_link_libraries(blue-${module_name}-s blue-${dep}-s) endforeach (dep) - set_target_properties(blue-${module_name}-obj PROPERTIES FOLDER "Modules/${module_name}") - set_target_properties(blue-${module_name} PROPERTIES FOLDER "Binaries/${module_name}") - set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Binaries/${module_name}") + set_target_properties(blue-${module_name} PROPERTIES FOLDER "Shared/${module_name}") + set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Static/${module_name}") install(TARGETS blue-${module_name} blue-${module_name}-s) install(FILES ${root_header} DESTINATION include/blue)