forked from cpp-netlib/uri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
102 lines (79 loc) · 3.01 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
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
98
99
100
101
102
# Copyright (c) Glyn Matthews 2012-2017.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 2.8)
project(Uri)
option(Uri_BUILD_TESTS "Build the URI tests." ON)
option(Uri_BUILD_DOCS "Build the URI documentation." ON)
option(Uri_FULL_WARNINGS "Build the library with all warnings turned on." ON)
option(Uri_WARNINGS_AS_ERRORS "Treat warnings as errors." ON)
option(Uri_USE_STATIC_CRT "Use static C Runtime library (/MT or MTd)." ON)
find_package(Threads REQUIRED)
set(CMAKE_VERBOSE_MAKEFILE true)
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
if (HAVE_STD11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(FATAL_ERROR "No C++ 11 support (Compiler does not define -std=c++11).")
endif()
if (Uri_FULL_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
if (Uri_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (NOT Uri_DISABLE_LIBCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if (Uri_FULL_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
if (Uri_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
endif()
if (MSVC)
if(DEFINED MSVC_VERSION AND MSVC_VERSION LESS 1900)
message(FATAL_ERROR "Requires VS 2015 or later")
endif()
if (Uri_USE_STATIC_CRT)
# Replace dynamic MSVCRT linker flags with static version.
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif(Uri_USE_STATIC_CRT)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC)
include_directories(${Uri_SOURCE_DIR}/src ${Uri_SOURCE_DIR}/include)
add_subdirectory(src)
# Testing
if (Uri_BUILD_TESTS)
message(STATUS "Configuring tests")
enable_testing()
add_subdirectory(deps/googletest)
add_subdirectory(test)
endif()
# Documentation
if (Uri_BUILD_DOCS)
message("Configuring documentation")
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM)
endif()
endif()
install(DIRECTORY include DESTINATION ".")