forked from ibc/libsdptransform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
66 lines (55 loc) · 2.35 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cmake_minimum_required(VERSION 3.19)
# Read version from vcpkg.json
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON)
string(JSON MANIFEST_PROJECT_NAME GET ${VCPKG_JSON} "name")
string(JSON MANIFEST_PROJECT_VERSION GET ${VCPKG_JSON} "version")
string(JSON MANIFEST_PROJECT_DESCRIPTION GET ${VCPKG_JSON} "description")
project(${MANIFEST_PROJECT_NAME}
VERSION ${MANIFEST_PROJECT_VERSION}
DESCRIPTION ${MANIFEST_PROJECT_DESCRIPTION})
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(SDPTRANSFORM_BUILD_TESTS "Build tests" OFF)
option(SDPTRANSFORM_BUILD_README_HELPER "Build readme helper" OFF)
find_package(nlohmann_json CONFIG REQUIRED)
if (SDPTRANSFORM_BUILD_TESTS)
add_subdirectory(test)
endif()
if (SDPTRANSFORM_BUILD_README_HELPER)
add_subdirectory(readme-helper)
endif()
set(SOURCE_FILES
src/grammar.cpp
src/parser.cpp
src/writer.cpp
)
set(HEADER_FILES
include/sdptransform.hpp
)
add_library(${CMAKE_PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC nlohmann_json::nlohmann_json)
# Install project to make it available using find_package
install(TARGETS ${CMAKE_PROJECT_NAME}
EXPORT ${CMAKE_PROJECT_NAME}-targets)
install(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE ${CMAKE_PROJECT_NAME}-targets.cmake
DESTINATION cmake)
install(FILES ${HEADER_FILES}
DESTINATION include/${CMAKE_PROJECT_NAME})
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-config.cmake
INSTALL_DESTINATION cmake)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-version.cmake
DESTINATION
cmake)
export(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-targets.cmake)