-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
60 lines (45 loc) · 2.61 KB
/
CMakeLists.txt
File metadata and controls
60 lines (45 loc) · 2.61 KB
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
cmake_minimum_required(VERSION 3.1)
project(iconpp LANGUAGES CXX VERSION 1.0)
# --------------------------------------------------------------------------------------------------------
# Create library
# --------------------------------------------------------------------------------------------------------
if (UNIX)
add_library(${PROJECT_NAME} "src/icon.cpp")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Werror -Wextra -pedantic)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
else()
add_library(${PROJECT_NAME} INTERFACE) # Create empty library on unsupported platform
endif()
# --------------------------------------------------------------------------------------------------------
# Include "include" folder
# --------------------------------------------------------------------------------------------------------
target_include_directories(${PROJECT_NAME} PUBLIC "include")
# --------------------------------------------------------------------------------------------------------
# Link required libraries
# --------------------------------------------------------------------------------------------------------
include(FetchContent)
FetchContent_Declare(expected GIT_REPOSITORY "https://github.com/TartanLlama/expected")
option(EXPECTED_BUILD_TESTS "" OFF)
option(EXPECTED_BUILD_PACKAGE "" OFF)
FetchContent_MakeAvailable(expected)
target_link_libraries(${PROJECT_NAME} PRIVATE dl PUBLIC tl::expected)
# --------------------------------------------------------------------------------------------------------
# Tests
# --------------------------------------------------------------------------------------------------------
option(iconpp_tests "Build tests" OFF)
if (${iconpp_tests} AND UNIX)
message(STATUS "Building iconpp tests")
if (NOT TARGET Catch2::Catch2WithMain)
include(FetchContent)
FetchContent_Declare(Catch2 GIT_REPOSITORY "https://github.com/catchorg/Catch2" GIT_TAG v2.13.7)
option(CATCH_BUILD_STATIC_LIBRARY "" ON)
FetchContent_MakeAvailable(Catch2)
endif()
file(GLOB src "tests/*.cpp")
add_executable(${PROJECT_NAME}_tests ${src})
target_link_libraries(${PROJECT_NAME}_tests PRIVATE Catch2::Catch2WithMain ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME}_tests PRIVATE cxx_std_17)
target_compile_options(${PROJECT_NAME}_tests PRIVATE -Wall -Werror -Wextra -pedantic)
set_target_properties(${PROJECT_NAME}_tests PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
endif()