-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
55 lines (42 loc) · 1.94 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.6)
project(alg_eng_matrix)
message(${CMAKE_CXX_COMPILER_ID})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("Adding -std=c++14 and -O3 for GNU C++ Compiler.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -std=c++14 -fopenmp -O3") # -O2 -O3
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("Adding /D_CRT_SECURE_NO_WARNINGS= /O2 /Ot /Og /Oi /Oy /Ox /Ob2 for MSVC.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS= /O2 /Ot /Oi /Oy /Ox /Ob2")
else ()
message("Neither GNU nor MSVC: No additional flags added to the compiler.")
endif ()
set(outdir ${CMAKE_CURRENT_SOURCE_DIR}/output)
add_custom_target(build-time-make-dir ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir})
file(GLOB SOURCE_FILES
"src/*.cpp"
"src/*.hpp")
file(GLOB TEST_FILES
"test/test.cpp"
"test/lib/catch.hpp"
"test/tests/*.cpp")
file(GLOB PCM
"../pcm/*.o")
ADD_LIBRARY(papi STATIC IMPORTED)
SET_TARGET_PROPERTIES(papi PROPERTIES IMPORTED_LOCATION /usr/local/lib/libpapi.a)
message(${SOURCE_FILES})
add_library(CORE ${SOURCE_FILES} ${PCM})
add_executable(main ${SOURCE_FILES})
set_target_properties(main PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${outdir})
target_link_libraries(main papi)
add_executable(testing ${TEST_FILES})
set_target_properties(testing PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${outdir})
target_link_libraries(testing CORE)
add_executable(benchmark "benchmark/benchmark.cpp")
set_target_properties(benchmark PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${outdir})
target_link_libraries(benchmark CORE papi)
add_executable(benchmark2 "benchmark/benchmark2.cpp")
set_target_properties(benchmark2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${outdir})
target_link_libraries(benchmark2 CORE papi)
add_executable(datagen "datagen/datagen.cpp")
set_target_properties(datagen PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${outdir})
target_link_libraries(datagen CORE)