File: CMakeLists.txt

package info (click to toggle)
libdivide 1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 232 kB
  • sloc: cpp: 1,917; ansic: 1,005; makefile: 2
file content (64 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
cmake_minimum_required(VERSION 3.1)
project(libdivide C CXX)
include(CheckCXXCompilerFlag)
include(CMakePushCheckState)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLIBDIVIDE_ASSERTIONS_ON")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLIBDIVIDE_ASSERTIONS_ON")

# By default enable release mode ###############################

string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)

if(NOT "${BUILD_TYPE}" MATCHES DEBUG)
    set(CMAKE_BUILD_TYPE Release)
endif()

# Enable GCC/Clang warnings ####################################

set(WALL_FLAGS "-Wall -Wno-unknown-pragmas -fstrict-aliasing")
check_cxx_compiler_flag("${WALL_FLAGS}" wall)

if(wall)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WALL_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WALL_FLAGS}")
endif()

# Check -msse2 compiler flag ###################################

cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS -Werror)
check_cxx_compiler_flag(-msse2 msse2)
cmake_pop_check_state()

if(msse2)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
    add_definitions(-DLIBDIVIDE_USE_SSE2)
endif()

# Build test programs ##########################################

find_package(Threads REQUIRED)

add_executable(tester test/tester.cpp)
add_executable(benchmark test/benchmark.c)
add_executable(primes_benchmark test/primes_benchmark.cpp)

target_include_directories(tester PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(benchmark PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(primes_benchmark PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")

target_link_libraries(tester Threads::Threads)

# Enable testing ###############################################

enable_testing()
add_test(tester tester)
add_test(primes_benchmark primes_benchmark)

# By default install to /usr/local/install #####################

install(FILES libdivide.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)