diff options
author | iphydf <iphydf@users.noreply.github.com> | 2017-06-04 00:36:18 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2017-06-04 10:08:51 +0000 |
commit | cda770cfe174b24993946f82200126bdcca75c4d (patch) | |
tree | 98f29d6b9e09fb1ec8300566b6e58859721c95d9 /cmake | |
parent | d4be41a3ad1ab01d7c5d475b353d9a1e3d17d31c (diff) |
Forbid undefined symbols in shared libraries.
Also a little bit of refactoring:
- Moved add_cflag and friends from CMakeLists.txt to a separate
AddCompilerFlag module.
- Build the spectest SUT if msgpack is found, even if spectest itself is
not found, so once it exists, users can run it themselves or
reconfigure cmake.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/AddCompilerFlag.cmake | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cmake/AddCompilerFlag.cmake b/cmake/AddCompilerFlag.cmake new file mode 100644 index 00000000..78102dcc --- /dev/null +++ b/cmake/AddCompilerFlag.cmake | |||
@@ -0,0 +1,46 @@ | |||
1 | include(CheckCCompilerFlag) | ||
2 | include(CheckCXXCompilerFlag) | ||
3 | |||
4 | function(add_cflag flag) | ||
5 | string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" var ${flag}) | ||
6 | if(NOT DEFINED HAVE_C${var}) | ||
7 | message(STATUS "checking for C compiler flag: ${flag}") | ||
8 | endif() | ||
9 | set(CMAKE_REQUIRED_QUIET TRUE) | ||
10 | |||
11 | check_c_compiler_flag("${flag}" HAVE_C${var} QUIET) | ||
12 | if(HAVE_C${var}) | ||
13 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE) | ||
14 | endif() | ||
15 | endfunction() | ||
16 | |||
17 | function(add_cxxflag flag) | ||
18 | string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" var ${flag}) | ||
19 | if(NOT DEFINED HAVE_CXX${var}) | ||
20 | message(STATUS "checking for C++ compiler flag: ${flag}") | ||
21 | endif() | ||
22 | set(CMAKE_REQUIRED_QUIET TRUE) | ||
23 | |||
24 | check_cxx_compiler_flag("${flag}" HAVE_CXX${var} QUIET) | ||
25 | if(HAVE_CXX${var}) | ||
26 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) | ||
27 | endif() | ||
28 | endfunction() | ||
29 | |||
30 | function(add_dllflag flag) | ||
31 | string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" var ${flag}) | ||
32 | if(NOT DEFINED HAVE_LD${var}) | ||
33 | message(STATUS "checking for C++ compiler flag: ${flag}") | ||
34 | endif() | ||
35 | set(CMAKE_REQUIRED_QUIET TRUE) | ||
36 | |||
37 | check_c_compiler_flag("${flag}" HAVE_LD${var} QUIET) | ||
38 | if(HAVE_LD${var}) | ||
39 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}" PARENT_SCOPE) | ||
40 | endif() | ||
41 | endfunction() | ||
42 | |||
43 | macro(add_flag flag) | ||
44 | add_cflag(${flag}) | ||
45 | add_cxxflag(${flag}) | ||
46 | endmacro() | ||