Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
101 lines (90 loc) · 3.07 KB
/
Copy pathCMakeLists.txt
File metadata and controls
101 lines (90 loc) · 3.07 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
98
99
100
101
cmake_minimum_required(VERSION 2.6)
project(ASIO-cURL LANGUAGES CXX)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(CheckIncludeFileCXX)
function(add_linker_options)
foreach(arg ${ARGV})
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} ${arg}")
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}" PARENT_SCOPE)
endforeach(arg)
endfunction()
# Where our project's headers live
include_directories(include)
# We need libcurl
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
# General command line arguments to the compiler that should be present
# on all platforms
add_compile_options(-std=c++1z)
if(DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-O0 -g -fno-inline -fno-omit-frame-pointer -Wall -Wpedantic -Wextra -Werror)
# Address Sanitizer (non-Windows only)
if(NOT WIN32)
if(NOT DEFINED USE_ADDRESS_SANITIZER OR USE_ADDRESS_SANITIZER)
add_compile_options(-fsanitize=address)
add_linker_options(-fsanitize=address)
endif()
endif()
# Enable all warnings except a choice few on Clang
if (DEFINED CMAKE_CXX_COMPILER_ID AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Weverything)
# We don't care about C++98 compatibility: This is a C++14
# library
add_compile_options(-Wno-c++98-compat)
# These warnings are just noise
add_compile_options(-Wno-weak-vtables -Wno-padded)
# curl_easy_setopt is apparently implemented in terms of
# a recursive macro which sets this warning off
add_compile_options(-Wno-disabled-macro-expansion)
endif()
else()
add_compile_options(-O2)
endif()
if(NOT DEFINED USE_BOOST_FUTURE)
set(USE_BOOST_FUTURE 1)
endif()
if(NOT DEFINED USE_BOOST_ASIO)
set(USE_BOOST_ASIO 1)
endif()
configure_file(src/configure.hpp.in include/asiocurl/configure.hpp)
add_library(asiocurl SHARED
src/easy.cpp
src/exception.cpp
src/init.cpp
src/io_service.cpp
)
target_link_libraries(asiocurl ${CURL_LIBRARIES})
if (WIN32)
target_link_libraries(asiocurl ws2_32)
endif()
if(USE_BOOST_FUTURE)
target_link_libraries(asiocurl boost_thread)
endif()
if(USE_BOOST_ASIO OR USE_BOOST_FUTURE)
target_link_libraries(asiocurl boost_system)
endif()
if((DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug") OR (DEFINED BUILD_TESTS AND BUILD_TESTS))
add_executable(tests
src/test/easy.cpp
src/test/io_service.cpp
src/test/main.cpp
src/test/scope.cpp
)
target_link_libraries(tests asiocurl)
if(NOT WIN32)
target_link_libraries(tests pthread)
endif()
# Catch triggers -Wexit-time-destructors like crazy
# so we turn it off only for the tests
if (DEFINED CMAKE_CXX_COMPILER_ID AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(tests PRIVATE -Wno-exit-time-destructors)
endif()
add_custom_target(tests_run ALL
COMMAND tests
DEPENDS tests
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT "Run test suite"
)
endif()