Commit 7ca97fc0 authored by Alex Richardson's avatar Alex Richardson Committed by Branislav Katreniak

Simplify the install(TARGETS ...) CMake calls

parent f7d685be
...@@ -28,6 +28,14 @@ set(INCLUDE_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/include" ...@@ -28,6 +28,14 @@ set(INCLUDE_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/include"
CACHE PATH "Installation directory for header files (default: prefix/include)." CACHE PATH "Installation directory for header files (default: prefix/include)."
) )
# these arguments are passed to all install(TARGETS) calls
set(INSTALL_TARGETS_DEFAULT_ARGS
EXPORT CapnProtoTargets
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
)
# Options ====================================================================== # Options ======================================================================
option(BUILD_TOOLS "Build command-line tools and compiler." ON) option(BUILD_TOOLS "Build command-line tools and compiler." ON)
......
...@@ -59,7 +59,7 @@ add_library(capnp ${capnp_sources}) ...@@ -59,7 +59,7 @@ add_library(capnp ${capnp_sources})
target_link_libraries(capnp kj) target_link_libraries(capnp kj)
#make sure external consumers don't need to manually set the include dirs #make sure external consumers don't need to manually set the include dirs
target_include_directories(capnp INTERFACE $<INSTALL_INTERFACE:include>) target_include_directories(capnp INTERFACE $<INSTALL_INTERFACE:include>)
install(TARGETS capnp EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS capnp ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${capnp_headers} ${capnp_schemas} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp") install(FILES ${capnp_headers} ${capnp_schemas} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp")
set(capnp-rpc_sources set(capnp-rpc_sources
...@@ -91,7 +91,7 @@ set(capnp-rpc_schemas ...@@ -91,7 +91,7 @@ set(capnp-rpc_schemas
if(NOT CAPNP_LITE) if(NOT CAPNP_LITE)
add_library(capnp-rpc ${capnp-rpc_sources}) add_library(capnp-rpc ${capnp-rpc_sources})
target_link_libraries(capnp-rpc kj-async kj) target_link_libraries(capnp-rpc kj-async kj)
install(TARGETS capnp-rpc EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS capnp-rpc ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${capnp-rpc_headers} ${capnp-rpc_schemas} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp") install(FILES ${capnp-rpc_headers} ${capnp-rpc_schemas} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp")
endif() endif()
...@@ -111,7 +111,7 @@ set(capnp-json_schemas ...@@ -111,7 +111,7 @@ set(capnp-json_schemas
if(NOT CAPNP_LITE) if(NOT CAPNP_LITE)
add_library(capnp-json ${capnp-json_sources}) add_library(capnp-json ${capnp-json_sources})
target_link_libraries(capnp-json capnp kj-async kj) target_link_libraries(capnp-json capnp kj-async kj)
install(TARGETS capnp-json EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS capnp-json ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${capnp-json_headers} ${capnp-json_schemas} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp/compat") install(FILES ${capnp-json_headers} ${capnp-json_schemas} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp/compat")
endif() endif()
...@@ -132,7 +132,7 @@ set(capnpc_sources ...@@ -132,7 +132,7 @@ set(capnpc_sources
if(NOT CAPNP_LITE) if(NOT CAPNP_LITE)
add_library(capnpc ${capnpc_sources}) add_library(capnpc ${capnpc_sources})
target_link_libraries(capnpc capnp kj) target_link_libraries(capnpc capnp kj)
install(TARGETS capnpc EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS capnpc ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${capnpc_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp") install(FILES ${capnpc_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/capnp")
endif() endif()
...@@ -156,7 +156,7 @@ if(BUILD_TOOLS AND NOT CAPNP_LITE) ...@@ -156,7 +156,7 @@ if(BUILD_TOOLS AND NOT CAPNP_LITE)
target_link_libraries(capnpc_capnp capnp kj) target_link_libraries(capnpc_capnp capnp kj)
set_target_properties(capnpc_capnp PROPERTIES OUTPUT_NAME capnpc-capnp) set_target_properties(capnpc_capnp PROPERTIES OUTPUT_NAME capnpc-capnp)
install(TARGETS capnp_tool capnpc_cpp capnpc_capnp EXPORT CapnProtoTargets RUNTIME DESTINATION "${BIN_INSTALL_DIR}") install(TARGETS capnp_tool capnpc_cpp capnpc_capnp ${INSTALL_TARGETS_DEFAULT_ARGS})
# Symlink capnpc -> capnp # Symlink capnpc -> capnp
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink capnp \"\$ENV{DESTDIR}${BIN_INSTALL_DIR}/capnpc\")") install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink capnp \"\$ENV{DESTDIR}${BIN_INSTALL_DIR}/capnpc\")")
......
...@@ -64,7 +64,7 @@ endif() ...@@ -64,7 +64,7 @@ endif()
target_compile_definitions(kj PUBLIC ${CAPNP_LITE_FLAG}) target_compile_definitions(kj PUBLIC ${CAPNP_LITE_FLAG})
#make sure external consumers don't need to manually set the include dirs #make sure external consumers don't need to manually set the include dirs
target_include_directories(kj INTERFACE $<INSTALL_INTERFACE:include>) target_include_directories(kj INTERFACE $<INSTALL_INTERFACE:include>)
install(TARGETS kj EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS kj ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${kj_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj") install(FILES ${kj_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
install(FILES ${kj-parse_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/parse") install(FILES ${kj-parse_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/parse")
install(FILES ${kj-std_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/std") install(FILES ${kj-std_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/std")
...@@ -80,7 +80,7 @@ set(kj-test-compat_headers ...@@ -80,7 +80,7 @@ set(kj-test-compat_headers
) )
add_library(kj-test ${kj-test_sources}) add_library(kj-test ${kj-test_sources})
target_link_libraries(kj-test kj) target_link_libraries(kj-test kj)
install(TARGETS kj-test EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS kj-test ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${kj-test_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj") install(FILES ${kj-test_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
install(FILES ${kj-test-compat_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/compat") install(FILES ${kj-test-compat_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/compat")
...@@ -105,7 +105,7 @@ if(NOT CAPNP_LITE) ...@@ -105,7 +105,7 @@ if(NOT CAPNP_LITE)
# external clients of this library need to link to pthreads # external clients of this library need to link to pthreads
target_compile_options(kj-async INTERFACE "-pthread") target_compile_options(kj-async INTERFACE "-pthread")
endif() endif()
install(TARGETS kj-async EXPORT CapnProtoTargets ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") install(TARGETS kj-async ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ${kj-async_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj") install(FILES ${kj-async_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
endif() endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment