Browse Source

* update cmake files

* add option WITH_HARDENING
* add option WITH_TOOLS
master
Alex 'AdUser' Z 8 years ago
parent
commit
bc108a64bd
  1. 24
      CMakeLists.txt
  2. 2
      src/CMakeLists.txt

24
CMakeLists.txt

@ -5,11 +5,33 @@ project($CNAME C)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
include(CTest) include(CTest)
include(GNUInstallDirs)
option(WITH_HARDENING "Enable hardening options" ON)
option(WITH_TOOLS "Build library management tools" ON)
set(CMAKE_INSTALL_PREFIX "/usr/local") set(CMAKE_INSTALL_PREFIX "/usr/local")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99")
add_definitions("-D_XOPEN_SOURCE=500") add_definitions("-D_XOPEN_SOURCE=500")
add_subdirectory(src) if (WITH_HARDENING)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat -Wformat-security -Werror=format-security" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector --param ssp-buffer-size=4" )
add_definitions("-D_FORTIFY_SOURCE=2")
endif ()
message(STATUS "Project : ${CNAME} v${VERSION}")
message(STATUS "Compiler : ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
message(STATUS "- CFLAGS : ${CMAKE_C_FLAGS}")
message(STATUS "Paths:")
message(STATUS "- prefix : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "- binary : ${CMAKE_INSTALL_FULL_BINDIR}")
message(STATUS "- library : ${CMAKE_INSTALL_FULL_LIBDIR}")
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS "Options:")
message(STATUS "- WITH_HARDENING : ${WITH_HARDENING}")
message(STATUS "- WITH_TOOLS : ${WITH_TOOLS}")
add_subdirectory("src")
add_subdirectory("tests") add_subdirectory("tests")
set_property(DIRECTORY "tests" PROPERTY COMPILE_FLAGS "-g;-ggdb;-Wall;-Wextra;-pedantic;-O0") set_property(DIRECTORY "tests" PROPERTY COMPILE_FLAGS "-g;-ggdb;-Wall;-Wextra;-pedantic;-O0")

2
src/CMakeLists.txt

@ -4,6 +4,7 @@ add_library("simdb" SHARED ${LIB_SOURCES})
set_property(TARGET "simdb" PROPERTY SONAME ${VERSION}) set_property(TARGET "simdb" PROPERTY SONAME ${VERSION})
install(TARGETS "simdb" LIBRARY DESTINATION "lib") install(TARGETS "simdb" LIBRARY DESTINATION "lib")
if (WITH_TOOLS)
add_executable("simdb-1to2" "simdb-1to2.c") add_executable("simdb-1to2" "simdb-1to2.c")
install(TARGETS "simdb-1to2" RUNTIME DESTINATION "bin") install(TARGETS "simdb-1to2" RUNTIME DESTINATION "bin")
@ -18,3 +19,4 @@ target_link_libraries("simdb-write" "simdb")
target_link_libraries("simdb-write" ${ImageMagick_MagickCore_LIBRARY}) target_link_libraries("simdb-write" ${ImageMagick_MagickCore_LIBRARY})
target_link_libraries("simdb-write" ${ImageMagick_MagickWand_LIBRARY}) target_link_libraries("simdb-write" ${ImageMagick_MagickWand_LIBRARY})
install(TARGETS "simdb-write" RUNTIME DESTINATION "bin") install(TARGETS "simdb-write" RUNTIME DESTINATION "bin")
endif ()

Loading…
Cancel
Save