repertory/cmake/helpers.cmake
Scott E. Graves 99533a9687
All checks were successful
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
revert
2024-01-29 11:36:26 -06:00

56 lines
1.5 KiB
CMake

function(copy_support_files target)
if (MINGW)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/3rd_party/winfsp-${WINFSP_VERSION}/bin/${WINFSP_LIBRARY_BASENAME}.dll
${REPERTORY_OUTPUT_DIR}/${WINFSP_LIBRARY_BASENAME}.dll)
endif()
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/3rd_party/cacert.pem
${REPERTORY_OUTPUT_DIR}/cacert.pem)
endfunction(copy_support_files)
function(set_common_target_options name)
target_compile_definitions(${name} PUBLIC ${REPERTORY_DEFINITIONS})
target_precompile_headers(${name} PRIVATE include/common.hpp)
if (MACOS)
target_link_libraries(${name} PRIVATE -W1,-rpath,@executable_path)
set_target_properties(${name} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
endif()
if (UNIX OR MINGW)
target_compile_options(${name} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${REPERTORY_GCC_CXX_FLAGS}>
$<$<COMPILE_LANGUAGE:C>:${REPERTORY_GCC_FLAGS}>
)
endif()
endfunction(set_common_target_options)
function(add_project_executable name sources)
add_executable(${name}
src/main.cpp
${REPERTORY_HEADERS}
${sources}
)
set_common_target_options(${name})
add_dependencies(${name} librepertory)
if (REPERTORY_MUSL OR MINGW)
set_property(TARGET ${name} PROPERTY LINK_SEARCH_START_STATIC 1)
endif()
target_link_libraries(${name} PRIVATE librepertory)
copy_support_files(${name})
endfunction(add_project_executable)