11# Helper modules.
2- include (CheckFunctionExists)
3- include (CheckIncludeFile)
4-
5- # Setup options.
6- option (OPENMP "enable OpenMP support" OFF )
7- option (PCRE "enable PCRE support" OFF )
8- option (GKREGEX "enable GKREGEX support" OFF )
9- option (GKRAND "enable GKRAND support" OFF )
10-
112
123# Add compiler flags.
134if (MSVC )
145 set (GKlib_COPTIONS WIN32 MSC _CRT_SECURE_NO_DEPRECATE USE_GKREGEX)
15- elseif (WIN32 )
6+ elseif (MINGW )
167 set (GKlib_COPTIONS USE_GKREGEX)
178else ()
18- set (GKlib_COPTIONS LINUX FILE_OFFSET_BITS =64)
9+ set (GKlib_COPTIONS LINUX _FILE_OFFSET_BITS =64)
1910endif (MSVC )
2011
2112if (CYGWIN )
2213 list (APPEND GKlib_COPTIONS CYGWIN )
23- endif ()
14+ endif (CYGWIN )
2415
25- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
26- list (APPEND GKlib_COPTS -fno-strict-aliasing -Wall -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label)
16+ if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" )
17+ # GCC opts.
18+ list (APPEND GKlib_COPTS -fno-strict-aliasing)
19+
20+ # if(VALGRIND)
21+ # list(APPEND GKlib_COPTS -march=x86-64 -mtune=generic)
22+ # else()
23+ # list(APPEND GKlib_COPTS -march=native)
24+ # endif(VALGRIND)
2725endif ()
2826
2927if (UNIX )
@@ -32,63 +30,11 @@ check_pie_supported()
3230set (CMAKE_POSITION_INDEPENDENT_CODE true )
3331endif ()
3432
35- # Find OpenMP if it is requested.
36- if (OPENMP)
37- find_package (OpenMP REQUIRED)
38- list (APPEND GKlib_COPTIONS __OPENMP__)
39- endif ()
40-
4133# Set the CPU type
42- if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" )
43- list (APPEND GKlib_COPTIONS NO_X86=1)
44- endif ()
45-
46- # Add various options
47- if (PCRE)
48- list (APPEND GKlib_COPTIONS __WITHPCRE__)
49- endif ()
50-
51- if (GKREGEX)
52- list (APPEND GKlib_COPTIONS USE_GKREGEX)
53- endif ()
54-
55- if (GKRAND)
56- list (APPEND GKlib_COPTIONS USE_GKRAND)
57- endif ()
58-
59-
60- # Check for features.
61- check_include_file(execinfo.h HAVE_EXECINFO_H)
62- if (HAVE_EXECINFO_H)
63- list (APPEND GKlib_COPTIONS HAVE_EXECINFO_H)
64- endif (HAVE_EXECINFO_H)
34+ if (NO_X86)
35+ list (APPEND GKlib_COPTS -DNO_X86=${NO_X86} )
36+ endif (NO_X86)
6537
66- check_function_exists(getline HAVE_GETLINE)
67- if (HAVE_GETLINE)
68- list (APPEND GKlib_COPTIONS HAVE_GETLINE)
69- endif (HAVE_GETLINE)
70-
71-
72- # Custom check for TLS.
73- if (MSVC )
74- list (APPEND GKlib_COPTIONS __thread=__declspec(thread))
75-
76- # This if checks if that value is cached or not.
77- if ("${HAVE_THREADLOCALSTORAGE} " MATCHES "^${HAVE_THREADLOCALSTORAGE} $" )
78- message (CHECK_START "checking for thread-local storage" )
79- try_compile (HAVE_THREADLOCALSTORAGE
80- ${CMAKE_BINARY_DIR}
81- ${GKLIB_PATH} /conf/check_thread_storage.c)
82- if (HAVE_THREADLOCALSTORAGE)
83- message (CHECK_PASS "found" )
84- else ()
85- message (CHECK_FAIL "not found" )
86- endif ()
87- endif ()
88- if (NOT HAVE_THREADLOCALSTORAGE)
89- list (APPEND GKlib_COPTIONS __thread=)
90- endif ()
91- endif ()
9238
9339# Finally set the official C flags.
9440add_compile_options ("$<$<COMPILE_LANGUAGE:C>:${GKlib_COPTS} >" )
0 commit comments