2018-06-09 15:14:08 +00:00
|
|
|
cmake_minimum_required (VERSION 2.8)
|
|
|
|
|
|
|
|
project (pfaedle)
|
|
|
|
|
2019-04-01 19:56:52 +00:00
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
|
|
|
|
endif()
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
|
|
|
set(CPPLINT "${CMAKE_SOURCE_DIR}/cpplint.py")
|
|
|
|
include(cmake/cpplint.cmake)
|
|
|
|
endif()
|
2018-06-09 15:14:08 +00:00
|
|
|
|
|
|
|
set(CPPLINT_PROJECT_ROOT "src")
|
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build")
|
|
|
|
|
|
|
|
# set compiler flags, see http://stackoverflow.com/questions/7724569/debug-vs-release-in-cmake
|
2022-03-28 12:59:55 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "-Ofast -fno-signed-zeros -fno-trapping-math -Wall -Wno-format-extra-args -Wextra -Wformat-nonliteral -Wformat-security -Wformat=2 -Wextra -Wno-implicit-fallthrough -pedantic -Wno-keyword-macro")
|
2022-01-03 21:27:59 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_SANITIZE "-Og -g -fsanitize=address -fsanitize=leak -fsanitize=undefined -DLOGLEVEL=3 -DPFAEDLE_DBG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_PROFILE "-g -pg -DLOGLEVEL=3 -DPFAEDLE_DBG=1")
|
2018-07-24 17:33:18 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DLOGLEVEL=3 -DPFAEDLE_DBG=1")
|
2018-06-09 15:14:08 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -g -DLOGLEVEL=3")
|
|
|
|
|
|
|
|
# export compile commands to tools like clang
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
# Compiler-specific C++11 activation.
|
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
2018-07-22 16:37:03 +00:00
|
|
|
if ((GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8))
|
2018-06-09 15:14:08 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
else ()
|
2018-07-22 16:37:03 +00:00
|
|
|
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.8 or greater!")
|
2018-06-09 15:14:08 +00:00
|
|
|
endif ()
|
|
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
|
|
|
|
endif ()
|
|
|
|
|
2018-08-10 14:42:38 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPFAEDLE_PRECISION=${PFAEDLE_PRECISION}")
|
|
|
|
|
2018-06-09 15:14:08 +00:00
|
|
|
# http://brianmilco.blogspot.de/2012/11/cmake-automatically-use-git-tags-as.html
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
git_get_tag(VERSION_GIT)
|
|
|
|
get_git_is_dirty(VERSION_GIT_IS_DIRTY)
|
|
|
|
if ("${VERSION_GIT_IS_DIRTY}" STREQUAL "")
|
|
|
|
set(VERSION_GIT_FULL "${VERSION_GIT}")
|
|
|
|
else()
|
|
|
|
set(VERSION_GIT_FULL "${VERSION_GIT}-${VERSION_GIT_IS_DIRTY}")
|
|
|
|
endif()
|
|
|
|
|
2020-02-09 12:47:13 +00:00
|
|
|
# Download submodules if needed
|
|
|
|
|
2020-02-10 15:10:46 +00:00
|
|
|
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/src/configparser/.git OR NOT EXISTS ${CMAKE_SOURCE_DIR}/src/cppgtfs/.git OR NOT EXISTS ${CMAKE_SOURCE_DIR}/src/xml/.git)
|
|
|
|
execute_process(
|
|
|
|
COMMAND git submodule update --init --recursive
|
|
|
|
)
|
2020-02-09 12:47:13 +00:00
|
|
|
endif()
|
|
|
|
|
2018-06-09 15:14:08 +00:00
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
# tests
|
|
|
|
|
2018-07-22 15:40:06 +00:00
|
|
|
add_test("utilTest" utilTest)
|
2022-01-03 21:27:59 +00:00
|
|
|
add_test("pfaedleTest" pfaedleTest)
|
2018-06-09 15:14:08 +00:00
|
|
|
|
|
|
|
# handles install target
|
|
|
|
install(
|
2019-06-28 13:10:31 +00:00
|
|
|
FILES pfaedle.cfg DESTINATION etc/${PROJECT_NAME} COMPONENT config PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
2019-02-11 11:37:07 +00:00
|
|
|
)
|
2018-06-09 15:14:08 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
FILES build/pfaedle DESTINATION bin
|
2019-06-28 13:10:31 +00:00
|
|
|
PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE COMPONENT binaries
|
2019-02-11 11:37:07 +00:00
|
|
|
)
|
2022-01-03 21:27:59 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
FILES build/shapevl DESTINATION bin
|
|
|
|
PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE COMPONENT binaries
|
|
|
|
)
|