diff --git a/CMakeLists.txt b/CMakeLists.txt index b087bb4..be8baae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,38 @@ cmake_minimum_required(VERSION 3.12) -project(YYCCommonplace LANGUAGES CXX) +project(YYCC + VERSION 1.0.0 + LANGUAGES CXX +) -# Add core static library in build +# Import 2 build targets add_subdirectory(src) -# Add testbench code in build add_subdirectory(testbench) +# Install project package infos +# Package target +install(EXPORT YYCCommonplaceTargets + FILE YYCCommonplaceTargets.cmake + NAMESPACE YYCC:: + DESTINATION lib/cmake/YYCCommonplace +) +# Package configuration file +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + YYCCommonplaceConfigVersion.cmake + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMinorVersion +) +configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/cmake/YYCCommonplaceConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfig.cmake" + INSTALL_DESTINATION lib/cmake/YYCCommonplace +) +# Copy to install destination +install( +FILES + "${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfigVersion.cmake" +DESTINATION + lib/cmake/YYCCommonplace +) + diff --git a/cmake/YYCCommonplaceConfig.cmake.in b/cmake/YYCCommonplaceConfig.cmake.in new file mode 100644 index 0000000..e351d9a --- /dev/null +++ b/cmake/YYCCommonplaceConfig.cmake.in @@ -0,0 +1,2 @@ +# Add the targets file +include("${CMAKE_CURRENT_LIST_DIR}/YYCCommonplaceTargets.cmake") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a0137d..b145ccd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,23 +1,38 @@ -# Setup file lists up -set(YYCC_HEADER ${CMAKE_CURRENT_LIST_DIR}) -set(YYCC_SRC - ConsoleHelper.cpp - DialogHelper.cpp - EncodingHelper.cpp - ExceptionHelper.cpp - IOHelper.cpp - ParserHelper.cpp - StringHelper.cpp -) - # Create static library -add_library(YYCCommonplace - ${YYCC_SRC} +add_library(YYCCommonplace STATIC "") +# Setup static library sources +target_sources(YYCCommonplace +PRIVATE + # Headers + # Common headers + ${CMAKE_CURRENT_LIST_DIR}/ConsoleHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/DialogHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/EncodingHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/ExceptionHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/IOHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/ParserHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/StringHelper.hpp + # Windows including guard pair + ${CMAKE_CURRENT_LIST_DIR}/WinImportPrefix.hpp + ${CMAKE_CURRENT_LIST_DIR}/WinImportSuffix.hpp + # Misc + ${CMAKE_CURRENT_LIST_DIR}/YYCCInternal.hpp + ${CMAKE_CURRENT_LIST_DIR}/YYCCommonplace.hpp + + # Sources + ${CMAKE_CURRENT_LIST_DIR}/ConsoleHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/DialogHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/EncodingHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/ExceptionHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/IOHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/ParserHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/StringHelper.cpp ) # Setup header infomations target_include_directories(YYCCommonplace PUBLIC - ${YYCC_HEADER} + "$" + "$" ) # Setup C++ standard set_target_properties(YYCCommonplace @@ -37,3 +52,32 @@ target_compile_options(YYCCommonplace PRIVATE $<$:/utf-8> ) + +# Install project +# Install binary +install(TARGETS YYCCommonplace + EXPORT YYCCommonplaceTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) +# Install headers +install( +FILES + # Common headers + ${CMAKE_CURRENT_LIST_DIR}/ConsoleHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/DialogHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/EncodingHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/ExceptionHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/IOHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/ParserHelper.hpp + ${CMAKE_CURRENT_LIST_DIR}/StringHelper.hpp + # Windows including guard pair + ${CMAKE_CURRENT_LIST_DIR}/WinImportPrefix.hpp + ${CMAKE_CURRENT_LIST_DIR}/WinImportSuffix.hpp + # Misc + ${CMAKE_CURRENT_LIST_DIR}/YYCCInternal.hpp + ${CMAKE_CURRENT_LIST_DIR}/YYCCommonplace.hpp +DESTINATION include +) diff --git a/testbench/CMakeLists.txt b/testbench/CMakeLists.txt index 9eed591..811715e 100644 --- a/testbench/CMakeLists.txt +++ b/testbench/CMakeLists.txt @@ -1,6 +1,9 @@ # Create executable testbench -add_executable(Testbench - main.cpp +add_executable(Testbench "") +# Setup testbench sources +target_sources(Testbench +PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/main.cpp ) # Add YYCC as its library target_include_directories(Testbench @@ -23,3 +26,12 @@ target_compile_options(Testbench PRIVATE $<$:/utf-8> ) + +# Install binary +install(TARGETS Testbench + EXPORT TestbenchTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +)