Cmake: some fixes

This commit is contained in:
proller 2017-01-30 16:40:04 +03:00
parent 7ecfbfe53a
commit 33347ad9c3
4 changed files with 19 additions and 5 deletions

View File

@ -125,12 +125,12 @@ if (NOT APPLE)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GLIBC_COMPATIBILITY_LINK_FLAGS} ${CXX11_ABI_FLAGS}")
endif ()
if (USE_STATIC_LIBRARIES AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include (cmake/test_compiler.cmake)
if (USE_STATIC_LIBRARIES AND HAVE_NO_PIE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --no-pie")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --no-pie")
endif ()
set (SAN_FLAGS "-O3 -g -fno-omit-frame-pointer")
set (CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_ASAN} ${SAN_FLAGS} -fsanitize=address")
set (CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_ASAN} ${SAN_FLAGS} -fsanitize=address")

View File

@ -5,12 +5,13 @@ if (NOT READLINE_LIB)
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS})
endif ()
find_library (TERMCAP_LIB NAMES termcap)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.2)
find_library (TERMCAP_LIB NAMES termcap)
find_library (EDIT_LIB NAMES edit)
set(READLINE_INCLUDE_PATHS "/usr/local/opt/readline/include")
if (READLINE_LIB)
if (READLINE_LIB AND TERMCAP_LIB)
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS} NO_DEFAULT_PATH)
if (NOT READLINE_INCLUDE_DIR)
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS})
@ -40,5 +41,6 @@ check_cxx_source_runs("
int main() {
add_history(nullptr);
append_history(1,nullptr);
return 0;
}
" HAVE_READLINE_HISTORY)

View File

@ -1,5 +1,6 @@
if (APPLE)
find_library (RT_LIBRARIES apple_rt)
# lib from libs/libcommon
set (RT_LIBRARIES "apple_rt")
else ()
find_library (RT_LIBRARIES rt)
endif ()

11
cmake/test_compiler.cmake Normal file
View File

@ -0,0 +1,11 @@
include (CheckCXXSourceCompiles)
set (TEST_FLAG "--no-pie")
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG}")
check_cxx_source_compiles("
int main() {
return 0;
}
" HAVE_NO_PIE)
set (CMAKE_REQUIRED_FLAGS "")