build: update template for building assemblies
This commit is contained in:
+25
-53
@@ -1,4 +1,4 @@
|
||||
function(add_fx_module)
|
||||
function(add_fx_assembly)
|
||||
set(options)
|
||||
set(one_value_args NAME)
|
||||
set(multi_value_args
|
||||
@@ -13,7 +13,11 @@ function(add_fx_module)
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}")
|
||||
|
||||
set(module_name ${arg_NAME})
|
||||
set(assembly_name ${arg_NAME})
|
||||
string(REPLACE "." "/" assembly_path ${assembly_name})
|
||||
string(REPLACE "." "-" assembly_target_name ${assembly_name})
|
||||
string(REPLACE "." "_" assembly_token ${assembly_name})
|
||||
string(TOUPPER ${assembly_token} assembly_token)
|
||||
|
||||
file(GLOB sources *.c *.h)
|
||||
|
||||
@@ -23,87 +27,55 @@ function(add_fx_module)
|
||||
endforeach (dir)
|
||||
|
||||
file(GLOB sys_sources sys/${fx_system_name}/*.c sys/${fx_system_name}/*.h)
|
||||
set(root_header include/fx/${module_name}.h)
|
||||
file(GLOB headers include/fx/${module_name}/*.h)
|
||||
file(GLOB headers include/${assembly_path}/*.h)
|
||||
|
||||
string(REPLACE "-" "_" module_preproc_token ${module_name})
|
||||
string(TOUPPER ${module_preproc_token} module_preproc_token)
|
||||
set(module_preproc_token FX_${module_preproc_token})
|
||||
|
||||
message(STATUS "Building module ${module_name} (shared)")
|
||||
add_library(fx-${module_name} SHARED
|
||||
${sources}
|
||||
${sys_sources}
|
||||
${root_header}
|
||||
${headers}
|
||||
${arg_EXTRA_SOURCES})
|
||||
message(STATUS "Building module ${module_name} (static)")
|
||||
add_library(fx-${module_name}-s STATIC
|
||||
message(STATUS "Building assembly ${assembly_name}")
|
||||
add_library(${assembly_target_name} SHARED
|
||||
${sources}
|
||||
${sys_sources}
|
||||
${root_header}
|
||||
${headers}
|
||||
${arg_EXTRA_SOURCES})
|
||||
|
||||
target_include_directories(fx-${module_name} PUBLIC include/)
|
||||
target_include_directories(fx-${module_name}-s PUBLIC include/)
|
||||
target_include_directories(${assembly_target_name} PUBLIC include/)
|
||||
|
||||
target_compile_definitions(fx-${module_name} PUBLIC
|
||||
${module_preproc_token}
|
||||
target_compile_definitions(${assembly_target_name} PUBLIC
|
||||
${assembly_token}
|
||||
FX_EXPORT=1
|
||||
FX_ENABLE_FLOATING_POINT=${fx_enable_floating_point})
|
||||
target_compile_definitions(fx-${module_name}-s PUBLIC
|
||||
${module_preproc_token}
|
||||
FX_EXPORT=1
|
||||
FX_STATIC=1
|
||||
FX_ENABLE_FLOATING_POINT=${fx_enable_floating_point})
|
||||
|
||||
set_target_properties(fx-${module_name}
|
||||
set_target_properties(${assembly_target_name}
|
||||
PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
foreach (dep ${arg_DEPENDENCIES})
|
||||
target_link_libraries(fx-${module_name} fx-${dep})
|
||||
target_link_libraries(fx-${module_name}-s fx-${dep}-s)
|
||||
string(REPLACE "." "-" dep_target_name ${dep})
|
||||
target_link_libraries(${assembly_target_name} ${dep_target_name})
|
||||
endforeach (dep)
|
||||
|
||||
foreach (lib ${arg_LIBS})
|
||||
target_link_libraries(fx-${module_name} ${lib})
|
||||
target_link_libraries(fx-${module_name}-s ${lib})
|
||||
target_link_libraries(${assembly_target_name} ${lib})
|
||||
endforeach (lib)
|
||||
|
||||
foreach (dir ${arg_INCLUDE_DIRS})
|
||||
target_include_directories(fx-${module_name} PRIVATE
|
||||
${dir})
|
||||
target_include_directories(fx-${module_name}-s PRIVATE
|
||||
${dir})
|
||||
target_include_directories(${assembly_target_name} PRIVATE ${dir})
|
||||
endforeach (dir)
|
||||
|
||||
foreach (def ${arg_DEFINES})
|
||||
target_compile_definitions(fx-${module_name} PRIVATE
|
||||
${def})
|
||||
target_compile_definitions(fx-${module_name}-s PRIVATE
|
||||
${def})
|
||||
target_compile_definitions(${assembly_target_name} PRIVATE ${def})
|
||||
endforeach (def)
|
||||
|
||||
set_target_properties(fx-${module_name} PROPERTIES
|
||||
FOLDER "Shared/${module_name}")
|
||||
set_target_properties(fx-${module_name}-s PROPERTIES
|
||||
FOLDER "Static/${module_name}")
|
||||
set_target_properties(${assembly_target_name} PROPERTIES
|
||||
FOLDER "${assembly_name}")
|
||||
|
||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
||||
if(IS_BIG_ENDIAN)
|
||||
target_compile_definitions(fx-${module_name} PRIVATE
|
||||
BIG_ENDIAN)
|
||||
target_compile_definitions(fx-${module_name}-s PRIVATE
|
||||
target_compile_definitions(${assembly_target_name} PRIVATE
|
||||
BIG_ENDIAN)
|
||||
else()
|
||||
target_compile_definitions(fx-${module_name} PRIVATE
|
||||
LITTLE_ENDIAN)
|
||||
target_compile_definitions(fx-${module_name}-s PRIVATE
|
||||
target_compile_definitions(${assembly_target_name} PRIVATE
|
||||
LITTLE_ENDIAN)
|
||||
endif()
|
||||
|
||||
install(TARGETS fx-${module_name} fx-${module_name}-s)
|
||||
install(FILES ${root_header} DESTINATION include/fx)
|
||||
install(FILES ${headers} DESTINATION include/fx/${module_name})
|
||||
endfunction(add_fx_module)
|
||||
install(TARGETS ${assembly_target_name})
|
||||
install(FILES ${headers} DESTINATION include/${assembly_path})
|
||||
endfunction(add_fx_assembly)
|
||||
|
||||
Reference in New Issue
Block a user