libfort/CMakeLists.txt
2018-03-09 11:03:03 +03:00

63 lines
1.3 KiB
CMake

cmake_minimum_required(VERSION 2.8)
project(libfort)
option(FORT_TEST_BUILD "Test build with sanitizers and small library stack size" ON)
option(FORT_GCC_BUILD "Build with gcc" ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
include_directories(include)
include_directories(src)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g")
FILE(GLOB_RECURSE FortHeaders "include/*.h" "tests/*.h" "src/*.h" "src/*.h" "src/*.h" "src/*.h" "src/*.h" "src/*.h")
add_custom_target(headers SOURCES ${FortHeaders})
set(FORT_SOURCES
src/fort.c
src/vector.c
src/string_buffer.c
src/options.c
src/cell.c
src/row.c
src/table.c
src/fort_impl.c)
add_executable(${PROJECT_NAME}
example/main.c
${FORT_SOURCES})
include_directories(tests/cmocka-1.1.0/include)
link_directories(${CMAKE_SOURCE_DIR}/tests/cmocka-1.1.0/build/src)
add_executable(libfort_test
${FORT_SOURCES}
tests/test.c
tests/test_vector.c
tests/test_table.c
tests/test_string_buffer.c)
target_link_libraries(libfort_test
cmocka)
if(FORT_TEST_BUILD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
if(FORT_GCC_BUILD)
target_link_libraries(${PROJECT_NAME} asan)
target_link_libraries(libfort_test asan)
endif(FORT_GCC_BUILD)
endif(FORT_TEST_BUILD)