2022-09-04 21:26:29 +00:00
|
|
|
#add a library to pFlow with source files and target_link_libs (thouse under the main CMakeLists.txt)
|
2022-09-02 08:00:54 +00:00
|
|
|
macro(pFlow_add_library_install target_name src_files target_link_libs)
|
|
|
|
|
|
|
|
set(source_files ${${src_files}})
|
|
|
|
|
|
|
|
# add library
|
|
|
|
add_library(${target_name} ${source_files})
|
|
|
|
|
|
|
|
set_target_properties(${target_name} PROPERTIES
|
|
|
|
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${target_name} PUBLIC ${${target_link_libs}})
|
|
|
|
|
|
|
|
#get all valid the source files under the current folder
|
|
|
|
file(GLOB_RECURSE allValidFilePaths RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${validFiles})
|
|
|
|
|
|
|
|
set(validFilePathsExcSRCs ${allValidFilePaths})
|
|
|
|
foreach(file ${source_files})
|
|
|
|
list(REMOVE_ITEM validFilePathsExcSRCs ${file})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(includeDirs)
|
|
|
|
set(includeFiles ${validFilePathsExcSRCs})
|
|
|
|
|
|
|
|
# get the directory names
|
|
|
|
foreach(file_path ${validFilePathsExcSRCs})
|
|
|
|
GET_FILENAME_COMPONENT(dir_path ${file_path} DIRECTORY)
|
|
|
|
list(APPEND includeDirs ${dir_path})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
#remove duplicates
|
|
|
|
list(REMOVE_DUPLICATES includeDirs)
|
|
|
|
|
|
|
|
|
|
|
|
target_include_directories(${target_name}
|
|
|
|
PUBLIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${includeDirs}
|
|
|
|
)
|
|
|
|
|
|
|
|
message(STATUS "\nCreating make file for library ${target_name}")
|
|
|
|
message(STATUS " ${target_name} link libraries are: ${${target_link_libs}}")
|
|
|
|
message(STATUS " ${target_name} source files are: ${source_files}")
|
2023-09-27 07:58:39 +00:00
|
|
|
message(STATUS " ${target_name} include dirs are: ${includeDirs}\n \n")
|
2022-09-02 08:00:54 +00:00
|
|
|
|
|
|
|
install(TARGETS ${target_name} DESTINATION lib)
|
|
|
|
install(FILES ${includeFiles} DESTINATION include/${target_name})
|
|
|
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|