poafloc

poafloc - Parser Of Arguments For Lines Of Commands
git clone git://git.dimitrijedobrota.com/poafloc.git
Log | Files | Refs | README | LICENSE

commit f35303ec28b50839c56b8aac953e95b18379b610
parent 8e1b3a667bf03b1815ca20142771134a66c25cae
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 12 Jun 2024 17:10:02 +0200

Export targets for other CMake projects to use

Diffstat:
MCMakeLists.txt | 40++++++++++++++++++++++++++++++++++++++--
AargsConfig.cmake.in | 6++++++
Msrc/CMakeLists.txt | 2+-
3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -31,14 +31,15 @@ set(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory fo set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for header files") if(WIN32 AND NOT CYGWIN) set(DEF_INSTALL_CMAKEDIR CMake) +else() set(DEF_INSTALL_CMAKEDIR share/cmake/${PROJECT_NAME}) endif() -set(INSTALL_CMAKEDIR ${CMAKE_INSTALL_CMAKEDIR} CACHE PATH "Installation directory for CMake files") +set(INSTALL_CMAKEDIR ${DEF_INSTALL_CMAKEDIR} CACHE PATH "Installation directory for CMake files") message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}") message(STATUS "Project will be installed to ${CMAKE_INSTALL_PREFIX}") foreach(p LIB BIN INCLUDE CMAKE) - file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${ISNTALL_${p}DIR} _path) + file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_${p}DIR} _path) message(STATUS "installing ${p} components to ${_path}") unset(_path) endforeach() @@ -49,6 +50,8 @@ add_subdirectory(demo) install( TARGETS args + EXPORT + argsTargets ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT lib @@ -62,3 +65,36 @@ install( DESTINATION ${INSTALL_INCLUDEDIR}/args COMPONENT dev ) + +install( + EXPORT + argsTargets + NAMESPACE + "args::" + DESTINATION + ${INSTALL_CMAKEDIR} + COMPONENT + dev +) + +include(CMakePackageConfigHelpers) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/argsConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file( + ${PROJECT_SOURCE_DIR}/argsConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/argsConfig.cmake + INSTALL_DESTINATION ${INSTALL_CMAKEDIR} +) + +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/argsConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/argsConfigVersion.cmake + DESTINATION + ${INSTALL_CMAKEDIR} +) diff --git a/argsConfig.cmake.in b/argsConfig.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/argsTargets.cmake") + +check_required_components( + "args" +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(args STATIC args.cpp help.cpp trie.cpp c_bindings.cpp) -target_include_directories(args PUBLIC ../include) +target_include_directories(args PRIVATE ../include) target_compile_definitions(args PRIVATE WITH_C_BINDINGS) set_target_properties(args PROPERTIES LINKER_LANGUAGE CXX)