56 lines
2.6 KiB
CMake
56 lines
2.6 KiB
CMake
|
cmake_minimum_required(VERSION 2.6)
|
||
|
project("mbed TLS" C)
|
||
|
|
||
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
|
||
|
CACHE STRING "Choose the type of build: None Debug Release Coverage ASan ASanDbg MemSan MemSanDbg Check CheckFull"
|
||
|
FORCE)
|
||
|
|
||
|
string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}")
|
||
|
|
||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||
|
# some warnings we want are not available with old GCC versions
|
||
|
# note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION
|
||
|
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||
|
OUTPUT_VARIABLE GCC_VERSION)
|
||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings")
|
||
|
if (GCC_VERSION VERSION_GREATER 4.5 OR GCC_VERSION VERSION_EQUAL 4.5)
|
||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlogical-op")
|
||
|
endif()
|
||
|
if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
|
||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
|
||
|
endif()
|
||
|
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
||
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
||
|
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
||
|
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -O3")
|
||
|
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
|
||
|
set(CMAKE_C_FLAGS_CHECK "-Werror -Os")
|
||
|
set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual")
|
||
|
endif(CMAKE_COMPILER_IS_GNUCC)
|
||
|
|
||
|
if(CMAKE_COMPILER_IS_CLANG)
|
||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow")
|
||
|
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
||
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
||
|
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
||
|
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover -O3")
|
||
|
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
|
||
|
set(CMAKE_C_FLAGS_MEMSAN "-Werror -fsanitize=memory -O3")
|
||
|
set(CMAKE_C_FLAGS_MEMSANDBG "-Werror -fsanitize=memory -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2")
|
||
|
set(CMAKE_C_FLAGS_CHECK "-Werror -Os")
|
||
|
endif(CMAKE_COMPILER_IS_CLANG)
|
||
|
|
||
|
if(MSVC)
|
||
|
set(CMAKE_C_FLAGS_CHECK "/WX")
|
||
|
endif(MSVC)
|
||
|
|
||
|
if(LIB_INSTALL_DIR)
|
||
|
else()
|
||
|
set(LIB_INSTALL_DIR lib)
|
||
|
endif()
|
||
|
|
||
|
include_directories(include/)
|
||
|
|
||
|
add_subdirectory(library)
|
||
|
add_subdirectory(include)
|