-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
97 lines (74 loc) · 2.74 KB
/
CMakeLists.txt
File metadata and controls
97 lines (74 loc) · 2.74 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required(VERSION 3.1.0)
# Define library name and version
set(PARENT_PROJECT ${PROJECT_NAME})
project(imp) # Initialize PROJECT_xxx variables
set(IMP_VERSION_MAJOR 0)
set(IMP_VERSION_MINOR 1)
set(IMP_VERSION_REVISION 0)
set(CMAKE_CXX_STANDARD 14)
# compilation options
#option(BUILD_TESTS "Build the unit tests" OFF)
# Configure output directory
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# configure build modes
IF(CMAKE_BUILD_TYPE MATCHES Release)
add_definitions("-DNDEBUG")
ENDIF()
# TODO: use [add_compile_warnings] in new CMake instead of this
# configure compiler options
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -Wpedantic")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -Wpedantic")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX /EHsc")
# disable MS warning about safer *_s functions
add_compile_options(/wd4996)
endif()
# Generate and use config.h file
configure_file (
${PROJECT_SOURCE_DIR}/config.in
${PROJECT_BINARY_DIR}/include/imp/config
@ONLY # replace VAR with pattern @VAR@ only (not ${VAR})
)
add_definitions("-DHAVE_CONFIG_H") # define HAVE_CONFIG_H for project
include_directories(${PROJECT_BINARY_DIR}/include) # for config.h using
# Enumerate source files
set(SOURCES
src/version.cpp
)
# Enumerate header files
set(HEADERS
include/imp/version
include/imp/io/ppm
include/imp/io/pgm
include/imp/common/matrix
include/imp/image/rgb_image
include/imp/image/image
include/imp/image/operator
include/imp/filter/minmax
include/imp/common/iterator
include/imp/common/traits
)
# define and export library
add_library(imp STATIC ${SOURCES} ${HEADERS})
# use linker for C++ (CXX)
set_target_properties(imp PROPERTIES LINKER_LANGUAGE CXX
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON)
# populate headers
target_include_directories(imp PUBLIC ${PROJECT_SOURCE_DIR}/src/include) # internal headers
target_include_directories(imp PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(imp PUBLIC ${PROJECT_SOURCE_DIR}/external/eigen)
# initialize external libs
add_subdirectory(external)
# linking against libex and share its interface
target_link_libraries(imp PUBLIC ex)
# unit tests
if (BUILD_TESTS)
add_subdirectory(test)
message(STATUS "Test building enabled")
endif()