Skip to content

Commit a00e42c

Browse files
committed
more fixes
1 parent 2a80f6c commit a00e42c

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

CMakeLists.txt

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ project(facil-io VERSION 0.8.0
1313
set(LIB_ROOT lib)
1414
set(LIB_CONCAT_FOLDER fio-stl)
1515
include_directories(".")
16+
17+
include(CheckLibraryExists)
18+
include(CheckStructHasMember)
19+
include(CheckTypeSize)
20+
include(FeatureSummary)
21+
include(CheckCXXCompilerFlag)
22+
include(CheckCSourceCompiles)
23+
1624
find_library(MATH_LIBRARY m)
1725

1826
# default value of ${CMAKE_BUILD_TYPE} is Debug
@@ -30,7 +38,6 @@ option(FACIL_EXAMPLES_BUILD "Build Examples" OFF)
3038
option(FACIL_TESTS_BUILD "Build Tests" OFF)
3139

3240
# Detect endianess
33-
include(CheckTypeSize)
3441
check_type_size("void*" SIZE_OF_POINTER)
3542
if(${SIZE_OF_POINTER} EQUAL 8)
3643
set(FLAGS "__BIG_ENDIAN__")
@@ -48,11 +55,9 @@ if(FACIL_ENABLE_SODIUM)
4855
endif()
4956

5057
# Detect 'struct tm' fields
51-
include(CheckStructHasMember)
5258
check_struct_has_member("struct tm" tm_zone time.h HAVE_TM_TM_ZONE)
5359

5460
# Detect SystemV socket libraries
55-
include(CheckLibraryExists)
5661
check_library_exists(socket connect "" HAVE_SOCKET)
5762
check_library_exists(nsl gethostname "" HAVE_NSL)
5863
if(HAVE_SOCKET AND HAVE_NSL)
@@ -65,7 +70,6 @@ set(HAVE_SENDFILE FALSE)
6570
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
6671
# Detect the `sendfile` system call for Linux
6772
if(NOT HAVE_SENDFILE)
68-
include(CheckCSourceCompiles)
6973
check_c_source_compiles("
7074
#define _GNU_SOURCE
7175
#include <stdlib.h>
@@ -242,11 +246,19 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
242246
# Add sanitizers for GNU compilers (GCC or Clang)
243247
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -fstack-protector-all -g -DMALLOC_CHECK_=3 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
244248
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address -fsanitize=undefined")
249+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
245250
endif()
246251
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEBUG_FLAGS}")
247252
else()
248253
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${RELEASE_FLAGS}")
249254
endif()
255+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
256+
CHECK_CXX_COMPILER_FLAG("-stdlib=libc++" COMPILER_SUPPORTS_STATIC_CLANG)
257+
if(COMPILER_SUPPORTS_STATIC_CLANG)
258+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
259+
endif()
260+
endif()
261+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
250262

251263
# Create the library target
252264
if(FACIL_SHARED_BUILD)
@@ -315,7 +327,7 @@ if(FACIL_EXAMPLES_BUILD)
315327
set(EXAMPLES
316328
array
317329
bstr
318-
# chat
330+
chat
319331
client
320332
fiobj
321333
map
@@ -355,12 +367,12 @@ if(FACIL_TESTS_BUILD)
355367
# array
356368
base64
357369
# cpp
358-
# http1-parser-old
359-
# http1-parser
360-
# json
361-
# json_find
362-
# json_minify
363-
# malloc
370+
http1-parser-old
371+
http1-parser
372+
json
373+
json_find
374+
json_minify
375+
malloc
364376
mempool
365377
mustache
366378
noop
@@ -376,3 +388,4 @@ if(FACIL_TESTS_BUILD)
376388
build_and_run_test(${TEST})
377389
endforeach()
378390
endif()
391+
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

0 commit comments

Comments
 (0)