2017-01-30 13:40:04 +00:00
|
|
|
include (CheckCXXSourceCompiles)
|
2017-07-17 14:21:43 +00:00
|
|
|
include (CMakePushCheckState)
|
|
|
|
|
2017-11-24 22:48:34 +00:00
|
|
|
cmake_push_check_state ()
|
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
# clang4 : -no-pie cause error
|
|
|
|
# clang6 : -no-pie cause warning
|
2017-11-24 22:48:34 +00:00
|
|
|
|
2017-12-29 18:20:03 +00:00
|
|
|
if (MAKE_STATIC_LIBRARIES)
|
|
|
|
set (TEST_FLAG "-Wl,-Bstatic -stdlib=libc++ -lc++ -lc++abi -Wl,-Bdynamic")
|
|
|
|
else ()
|
|
|
|
set (TEST_FLAG "-stdlib=libc++ -lc++ -lc++abi")
|
|
|
|
endif ()
|
2017-11-24 22:48:34 +00:00
|
|
|
|
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG}")
|
|
|
|
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <iostream>
|
|
|
|
int main() {
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
2017-11-27 20:14:16 +00:00
|
|
|
" HAVE_LIBCXX)
|
2017-11-24 22:48:34 +00:00
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
else ()
|
2017-01-30 13:40:04 +00:00
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
cmake_push_check_state ()
|
2017-01-30 21:09:11 +00:00
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
set (TEST_FLAG "-no-pie")
|
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG}")
|
2017-01-30 13:40:04 +00:00
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
check_cxx_source_compiles("
|
|
|
|
int main() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_NO_PIE)
|
2017-01-30 21:09:11 +00:00
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
if (HAVE_NO_PIE)
|
|
|
|
set (FLAG_NO_PIE ${TEST_FLAG})
|
|
|
|
endif ()
|
|
|
|
|
2017-07-17 14:21:43 +00:00
|
|
|
|
2017-08-14 13:36:46 +00:00
|
|
|
endif ()
|
2017-11-24 22:48:34 +00:00
|
|
|
|
|
|
|
cmake_pop_check_state ()
|