-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
97 lines (80 loc) · 3.13 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required(VERSION 3.1)
project(JEC VERSION 0.1.0)
# Check platforms
if (CMAKE_HOST_WIN32)
set(WINDOWS 1)
message("The enviriment is in windows.")
elseif(CMAKE_HOST_APPLE)
set(MACOS 1)
message("The enviriment is in macos.")
elseif(CMAKE_HOST_UNIX)
set(LINUX 1)
message("The enviriment is in linux.")
endif()
#set(CMAKE_BUILD_TYPE Debug)
if (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (WINDOWS)
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O2 -Wall -g -ggdb")
else()
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
endif()
# Analyze performance
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
endif()
message("Build type: " ${CMAKE_BUILD_TYPE})
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MACOSX_RPATH OFF)
# add croaring
add_library(croaring STATIC ${PROJECT_SOURCE_DIR}/dependencies/CRoaring/roaring.c)
target_include_directories(croaring PUBLIC ${PROJECT_SOURCE_DIR}/dependencies/CRoaring/)
if (LINUX)
#find Opensmt library
get_filename_component(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake/" ABSOLUTE)
find_package(Opensmt REQUIRED)
#find GMP
get_filename_component(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake/" ABSOLUTE)
find_package(GMP REQUIRED)
#find CVC4 library
get_filename_component(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake/" ABSOLUTE)
find_package(CVC4 REQUIRED)
endif()
# the function is used to add all header files
function(include_sub_directories_recursively root_dir)
if (IS_DIRECTORY ${root_dir})
message("include dir: " ${root_dir})
include_directories(${root_dir})
endif()
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
foreach(sub ${ALL_SUB})
if (IS_DIRECTORY ${root_dir}/${sub})
# AND ((${sub} STREQUAL "circuit") OR (${sub} STREQUAL "ec") OR (${sub} STREQUAL "util"))
include_sub_directories_recursively(${root_dir}/${sub})
endif()
endforeach()
endfunction()
# add all header files
# include_sub_directories_recursively(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/include)
message("include dir: " ${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)
message("Source file: " ${SOURCE_FILES})
set(JEC_ALL_SRCS ${SOURCE_FILES} main.cpp)
add_executable(${PROJECT_NAME} ${JEC_ALL_SRCS})
if (LINUX)
target_include_directories(${PROJECT_NAME} PUBLIC ${OPENSMT_INCLUDE_DIR} ${CVC4_INCLUDE_DIR} ${GMP_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${OPENSMT_LIBRARY} ${CVC4_PARSER_LIBRARIES} ${CVC4_LIBRARIES} ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} ${CADICAL_LIBRARY})
endif()
target_link_libraries(${PROJECT_NAME} croaring)