build: add new parameters to module template
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
function(add_bluelib_module)
|
function(add_bluelib_module)
|
||||||
set(options)
|
set(options)
|
||||||
set(one_value_args NAME)
|
set(one_value_args NAME)
|
||||||
set(multi_value_args DEPENDENCIES SUBDIRS)
|
set(multi_value_args
|
||||||
cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${one_value_args}" "${multi_value_args}")
|
DEPENDENCIES
|
||||||
|
SUBDIRS
|
||||||
|
EXTRA_SOURCES
|
||||||
|
LIBS
|
||||||
|
INCLUDE_DIRS
|
||||||
|
DEFINES)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}")
|
||||||
|
|
||||||
set(module_name ${arg_NAME})
|
set(module_name ${arg_NAME})
|
||||||
|
|
||||||
@@ -22,15 +31,30 @@ function(add_bluelib_module)
|
|||||||
set(module_preproc_token BLUELIB_${module_preproc_token})
|
set(module_preproc_token BLUELIB_${module_preproc_token})
|
||||||
|
|
||||||
message(STATUS "Building module ${module_name} (shared)")
|
message(STATUS "Building module ${module_name} (shared)")
|
||||||
add_library(blue-${module_name} SHARED ${sources} ${sys_sources} ${root_header} ${headers})
|
add_library(blue-${module_name} SHARED
|
||||||
|
${sources}
|
||||||
|
${sys_sources}
|
||||||
|
${root_header}
|
||||||
|
${headers}
|
||||||
|
${arg_EXTRA_SOURCES})
|
||||||
message(STATUS "Building module ${module_name} (static)")
|
message(STATUS "Building module ${module_name} (static)")
|
||||||
add_library(blue-${module_name}-s STATIC ${sources} ${sys_sources} ${root_header} ${headers})
|
add_library(blue-${module_name}-s STATIC
|
||||||
|
${sources}
|
||||||
|
${sys_sources}
|
||||||
|
${root_header}
|
||||||
|
${headers}
|
||||||
|
${arg_EXTRA_SOURCES})
|
||||||
|
|
||||||
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} PUBLIC
|
||||||
target_compile_definitions(blue-${module_name}-s PUBLIC ${module_preproc_token} BLUELIB_EXPORT=1 BLUELIB_STATIC=1)
|
${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}
|
set_target_properties(blue-${module_name}
|
||||||
PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
@@ -40,16 +64,41 @@ function(add_bluelib_module)
|
|||||||
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} PROPERTIES FOLDER "Shared/${module_name}")
|
foreach (lib ${arg_LIBS})
|
||||||
set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Static/${module_name}")
|
target_link_libraries(blue-${module_name} ${lib})
|
||||||
|
target_link_libraries(blue-${module_name}-s ${lib})
|
||||||
|
endforeach (lib)
|
||||||
|
|
||||||
|
foreach (dir ${arg_INCLUDE_DIRS})
|
||||||
|
target_include_directories(blue-${module_name} PRIVATE
|
||||||
|
${dir})
|
||||||
|
target_include_directories(blue-${module_name}-s PRIVATE
|
||||||
|
${dir})
|
||||||
|
endforeach (dir)
|
||||||
|
|
||||||
|
foreach (def ${arg_DEFINES})
|
||||||
|
target_compile_definitions(blue-${module_name} PRIVATE
|
||||||
|
${def})
|
||||||
|
target_compile_definitions(blue-${module_name}-s PRIVATE
|
||||||
|
${def})
|
||||||
|
endforeach (def)
|
||||||
|
|
||||||
|
set_target_properties(blue-${module_name} PROPERTIES
|
||||||
|
FOLDER "Shared/${module_name}")
|
||||||
|
set_target_properties(blue-${module_name}-s PROPERTIES
|
||||||
|
FOLDER "Static/${module_name}")
|
||||||
|
|
||||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
||||||
if(IS_BIG_ENDIAN)
|
if(IS_BIG_ENDIAN)
|
||||||
target_compile_definitions(blue-${module_name} PRIVATE BIG_ENDIAN)
|
target_compile_definitions(blue-${module_name} PRIVATE
|
||||||
target_compile_definitions(blue-${module_name}-s PRIVATE BIG_ENDIAN)
|
BIG_ENDIAN)
|
||||||
|
target_compile_definitions(blue-${module_name}-s PRIVATE
|
||||||
|
BIG_ENDIAN)
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(blue-${module_name} PRIVATE LITTLE_ENDIAN)
|
target_compile_definitions(blue-${module_name} PRIVATE
|
||||||
target_compile_definitions(blue-${module_name}-s PRIVATE LITTLE_ENDIAN)
|
LITTLE_ENDIAN)
|
||||||
|
target_compile_definitions(blue-${module_name}-s PRIVATE
|
||||||
|
LITTLE_ENDIAN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS blue-${module_name} blue-${module_name}-s)
|
install(TARGETS blue-${module_name} blue-${module_name}-s)
|
||||||
|
|||||||
Reference in New Issue
Block a user