qsmaddy/CMakeLists.txt

81 行
2.5 KiB
CMake
Raw 通常表示 履歴

2017-12-26 11:42:57 +01:00
# This project is licensed under the MIT license. For more information see the
2017-12-25 12:22:35 +01:00
# LICENSE file.
cmake_minimum_required(VERSION 2.8)
project(maddy)
enable_testing()
# ------------------------------------------------------------------------------
set(MADDY_CPP_VERSION 14)
add_definitions(-DCPP_VERSION=${MADDY_CPP_VERSION})
# ------------------------------------------------------------------------------
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# ------------------------------------------------------------------------------
set(MADDY_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE MADDY_TESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/maddy/*.cpp)
# ------------------------------------------------------------------------------
2019-02-19 02:31:16 +01:00
if (UNIX)
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -std=c++${MADDY_CPP_VERSION} -Wall -Wpedantic -Wextra -Wno-ignored-qualifiers -fno-rtti -fno-exceptions -fsanitize=address -fno-omit-frame-pointer"
)
else()
set(
CMAKE_CXX_FLAGS
2019-02-19 02:34:39 +01:00
"${CMAKE_CXX_FLAGS} -std=c++${MADDY_CPP_VERSION}"
2019-02-19 02:31:16 +01:00
)
endif()
2017-12-25 12:22:35 +01:00
# ------------------------------------------------------------------------------
if (UNIX AND NOT APPLE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER}
-fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
message(STATUS "Found Gold linker, use faster linker")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold ")
endif()
endif()
# ------------------------------------------------------------------------------
2017-12-25 12:22:35 +01:00
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/gtest/googlemock)
add_subdirectory(libs)
# ------------------------------------------------------------------------------
2020-10-04 19:02:39 +02:00
add_library(maddy INTERFACE)
target_include_directories(maddy INTERFACE
2017-12-25 12:22:35 +01:00
${MADDY_INCLUDE_DIR}
)
# ------------------------------------------------------------------------------
add_executable(
MaddyTests
${MADDY_TESTS_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
)
2020-10-04 19:02:39 +02:00
target_include_directories(MaddyTests PUBLIC
${LIBS_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/tests
)
target_link_libraries(MaddyTests maddy gmock_main)
2017-12-25 12:22:35 +01:00
add_test(MaddyTests ${CMAKE_CURRENT_SOURCE_DIR}/build/MaddyTests)