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
56432321b8
commit
94c09511dd
@ -36,6 +36,7 @@ enable_testing()
|
||||
|
||||
option(CXXOPTS_BUILD_EXAMPLES "Set to ON to build examples" 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
|
||||
if (CXXOPTS_CXX_STANDARD)
|
||||
@ -70,6 +71,7 @@ target_include_directories(cxxopts INTERFACE
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
if(CXXOPTS_ENABLE_INSTALL)
|
||||
include(CMakePackageConfigHelpers)
|
||||
set(CXXOPTS_CMAKE_DIR "lib/cmake/cxxopts" CACHE STRING
|
||||
"Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.")
|
||||
@ -99,6 +101,7 @@ install(EXPORT ${targets_export_name} DESTINATION ${CXXOPTS_CMAKE_DIR}
|
||||
# Install the header file and export the target
|
||||
install(TARGETS cxxopts EXPORT ${targets_export_name} DESTINATION lib)
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/include/cxxopts.hpp DESTINATION include)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(test)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user