@@ -3,37 +3,44 @@ project(ncrypto VERSION 1.0.1) # x-release-please-version
33
44include (CTest )
55include (GNUInstallDirs )
6- include (FetchContent )
76include (cmake/ncrypto-flags.cmake )
87
98if (NOT CMAKE_BUILD_TYPE )
109 message (STATUS "No build type selected, default to Release" )
1110 set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
1211endif ()
1312
14- include (cmake/CPM.cmake )
13+ if (NCRYPTO_SHARED_LIBS)
14+ find_package (OpenSSL REQUIRED )
15+ else ()
16+ include (FetchContent )
17+ include (cmake/CPM.cmake )
1518
16- CPMAddPackage (
19+ CPMAddPackage (
1720 NAME boringssl
1821 VERSION 0.20250818.0
1922 GITHUB_REPOSITORY google/boringssl
2023 GIT_TAG 0.20250818.0
2124 OPTIONS "BUILD_SHARED_LIBS OFF" "BUILD_TESTING OFF"
22- )
25+ )
26+ endif ()
27+
2328add_subdirectory (src )
2429add_library (ncrypto::ncrypto ALIAS ncrypto )
2530
26- include_directories (${boringssl_SOURCE_DIR} /include )
27-
2831if (NCRYPTO_TESTING)
29- CPMAddPackage (
32+ if (NCRYPTO_SHARED_LIBS)
33+ find_package (GTest REQUIRED )
34+ else ()
35+ CPMAddPackage (
3036 NAME GTest
3137 GITHUB_REPOSITORY google/googletest
3238 VERSION 1.15.2
3339 OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF"
34- )
35- # For Windows: Prevent overriding the parent project's compiler/linker settings
36- set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
40+ )
41+ # For Windows: Prevent overriding the parent project's compiler/linker settings
42+ set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
43+ endif ()
3744 enable_testing ()
3845 add_subdirectory (tests )
3946endif ()
@@ -53,3 +60,15 @@ install(
5360 ARCHIVE COMPONENT ncrypto_development
5461 INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} "
5562)
63+
64+ # Generate pkg-config file
65+ configure_file (
66+ ${CMAKE_CURRENT_SOURCE_DIR} /ncrypto.pc.in
67+ ${CMAKE_CURRENT_BINARY_DIR} /ncrypto.pc
68+ @ONLY
69+ )
70+
71+ install (
72+ FILES ${CMAKE_CURRENT_BINARY_DIR} /ncrypto.pc
73+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig
74+ )
0 commit comments