Meta: Symlink docs/relnotes/relnotes-2.0 to NEWS
[link.git] / CMakeLists.txt
blob7dbaad62981df37d6e594725cc2a0408bbdf495b
1 cmake_minimum_required(VERSION 3.20.2)
2 project(Link)
4 find_package(OpenSSL 3 REQUIRED)
6 # Versioning
7 set(LINK_VERSION 2)
8 set(LINK_VERSION_MINOR 0)
9 set(LINK_VERSION_PATCH 0)
10 set(LINK_VERSION_EXTRA "rc3")
12 set(VERSION ${LINK_VERSION}.${LINK_VERSION_MINOR}.${LINK_VERSION_PATCH}-${LINK_VERSION_EXTRA})
14 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL 8.0)
15         message(STATUS "GCC version is <= 8.0. -DFS_EXPERIMENTAL")
16 endif()
18 # Library
19 file(GLOB_RECURSE SOURCES Source/*.cpp)
20 file(GLOB_RECURSE INCLUDES Include/*)
22 include_directories(Include)
24 add_library(link SHARED ${SOURCES})
25 set_target_properties(link PROPERTIES
26     PUBLIC_HEADER ${INCLUDES})
28 set_target_properties(link PROPERTIES
29                 VERSION ${VERSION}
30                 SOVERSION ${LINK_VERSION})
32 target_compile_features(link PUBLIC cxx_std_17)
33 set (CMAKE_CXX_FLAGS "-std=c++17")
35 target_include_directories(link PUBLIC Include)
36 target_link_libraries(link PUBLIC OpenSSL::SSL z)
38 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL 8.0)
39         target_link_libraries(link PUBLIC stdc++fs)
40         set (CMAKE_CXX_FLAGS "-DFS_EXPERIMENTAL")
41 endif()
43 # install
44 install(TARGETS link
45     LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
46     PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
48 # Test
49 file(GLOB_RECURSE TEST_SOURCES Test/*.cpp)
51 if (BUILD_LINKTEST)
52         add_executable(linktest ${TEST_SOURCES})
53         target_link_libraries(linktest PRIVATE link)
55         enable_testing()
57         add_test(NAME test COMMAND $<TARGET_FILE:linktest>)
58 endif()