cmake: remove intermediate object libraries
this is so static and shared code can be compiled separately by MSVC
This commit is contained in:
@@ -11,38 +11,31 @@ function(add_bluelib_module)
|
|||||||
set(root_header include/blue/${module_name}.h)
|
set(root_header include/blue/${module_name}.h)
|
||||||
file(GLOB headers 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(REPLACE "-" "_" module_preproc_token ${module_name})
|
||||||
string(TOUPPER ${module_preproc_token} module_preproc_token)
|
string(TOUPPER ${module_preproc_token} module_preproc_token)
|
||||||
set(module_preproc_token BLUELIB_${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)")
|
message(STATUS "Building module ${module_name} (shared)")
|
||||||
add_library(blue-${module_name} SHARED $<TARGET_OBJECTS:blue-${module_name}-obj>)
|
add_library(blue-${module_name} SHARED ${sources} ${sys_sources} ${root_header} ${headers})
|
||||||
message(STATUS "Building module ${module_name} (static)")
|
message(STATUS "Building module ${module_name} (static)")
|
||||||
add_library(blue-${module_name}-s STATIC $<TARGET_OBJECTS:blue-${module_name}-obj>)
|
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} PUBLIC include/)
|
||||||
target_include_directories(blue-${module_name}-s 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})
|
foreach (dep ${arg_DEPENDENCIES})
|
||||||
target_link_libraries(blue-${module_name} blue-${dep})
|
target_link_libraries(blue-${module_name} blue-${dep})
|
||||||
target_link_libraries(blue-${module_name}-s blue-${dep}-s)
|
target_link_libraries(blue-${module_name}-s blue-${dep}-s)
|
||||||
endforeach (dep)
|
endforeach (dep)
|
||||||
|
|
||||||
set_target_properties(blue-${module_name}-obj PROPERTIES FOLDER "Modules/${module_name}")
|
set_target_properties(blue-${module_name} PROPERTIES FOLDER "Shared/${module_name}")
|
||||||
set_target_properties(blue-${module_name} PROPERTIES FOLDER "Binaries/${module_name}")
|
set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Static/${module_name}")
|
||||||
set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Binaries/${module_name}")
|
|
||||||
|
|
||||||
install(TARGETS blue-${module_name} blue-${module_name}-s)
|
install(TARGETS blue-${module_name} blue-${module_name}-s)
|
||||||
install(FILES ${root_header} DESTINATION include/blue)
|
install(FILES ${root_header} DESTINATION include/blue)
|
||||||
|
|||||||
Reference in New Issue
Block a user