Add CMake option CXXOPTS_ENABLE_INSTALL (#195)
Install targets will not be generated if this option is set to OFF, which is useful when including it as a bundled dependency of another project.
This commit is contained in:
parent
531c00b96f
commit
6e31c227e2
@ -36,6 +36,7 @@ enable_testing()
|
|||||||
|
|
||||||
option(CXXOPTS_BUILD_EXAMPLES "Set to ON to build examples" ON)
|
option(CXXOPTS_BUILD_EXAMPLES "Set to ON to build examples" ON)
|
||||||
option(CXXOPTS_BUILD_TESTS "Set to ON to build tests" ON)
|
option(CXXOPTS_BUILD_TESTS "Set to ON to build tests" ON)
|
||||||
|
option(CXXOPTS_ENABLE_INSTALL "Generate the install target" ON)
|
||||||
|
|
||||||
# request c++11 without gnu extension for the whole project and enable more warnings
|
# request c++11 without gnu extension for the whole project and enable more warnings
|
||||||
if (CXXOPTS_CXX_STANDARD)
|
if (CXXOPTS_CXX_STANDARD)
|
||||||
@ -71,6 +72,7 @@ target_include_directories(cxxopts INTERFACE
|
|||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CXXOPTS_ENABLE_INSTALL)
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
set(CXXOPTS_CMAKE_DIR "lib/cmake/cxxopts" CACHE STRING
|
set(CXXOPTS_CMAKE_DIR "lib/cmake/cxxopts" CACHE STRING
|
||||||
"Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.")
|
"Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.")
|
||||||
@ -100,6 +102,7 @@ install(EXPORT ${targets_export_name} DESTINATION ${CXXOPTS_CMAKE_DIR}
|
|||||||
# Install the header file and export the target
|
# Install the header file and export the target
|
||||||
install(TARGETS cxxopts EXPORT ${targets_export_name} DESTINATION lib)
|
install(TARGETS cxxopts EXPORT ${targets_export_name} DESTINATION lib)
|
||||||
install(FILES ${PROJECT_SOURCE_DIR}/include/cxxopts.hpp DESTINATION include)
|
install(FILES ${PROJECT_SOURCE_DIR}/include/cxxopts.hpp DESTINATION include)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user