-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
121 lines (91 loc) · 3.42 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
cmake_minimum_required(VERSION 3.18.4)
project(polyhedral-tutor)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
# list(APPEND CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR})
include(FetchContent)
FetchContent_Declare(
googletest
DOWNLOAD_EXTRACT_TIMESTAMP On
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
# set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
FetchContent_Declare(
pet
GIT_REPOSITORY https://repo.or.cz/pet.git
GIT_TAG master
GIT_SHALLOW ON
# GIT_SUBMODULES ""
# GIT_SUBMODULES_RECURSE False
# UPDATE_DISCONNECTED ON
)
FetchContent_MakeAvailable(pet)
set(ENV{PKG_CONFIG_PATH} "${pet_SOURCE_DIR}:${pet_SOURCE_DIR}/isl:$ENV{PKG_CONFIG_PATH}")
list(APPEND CMAKE_LIBRARY_PATH "${pet_BINARY_DIR}/lib")
list(APPEND CMAKE_INSTALL_RPATH "${pet_BINARY_DIR}/lib")
find_package(PkgConfig REQUIRED)
pkg_check_modules(ISL IMPORTED_TARGET isl)
pkg_check_modules(PET IMPORTED_TARGET pet)
if(ISL_FOUND)
message("ISL found")
set(PET_CONFIGURE_WITH_ISL system)
else()
message("ISL NOT found")
set(PET_CONFIGURE_WITH_ISL bundled)
endif()
if(NOT PET_FOUND)
message("Package 'pet' not found, but don't worry, I know how to build it!")
set(ENV{CC} ${CMAKE_C_COMPILER})
set(ENV{CXX} ${CMAKE_CXX_COMPILER})
execute_process(
# OUTPUT_QUIET
COMMAND ./autogen.sh
WORKING_DIRECTORY ${pet_SOURCE_DIR}
)
execute_process(
# OUTPUT_QUIET
COMMAND ./configure --prefix=${pet_BINARY_DIR} --with-isl=${PET_CONFIGURE_WITH_ISL}
WORKING_DIRECTORY ${pet_SOURCE_DIR}
)
execute_process(
# OUTPUT_QUIET
COMMAND make -j
WORKING_DIRECTORY ${pet_SOURCE_DIR}
)
execute_process(
# OUTPUT_QUIET
COMMAND make -j install
WORKING_DIRECTORY ${pet_SOURCE_DIR}
)
pkg_check_modules(PET REQUIRED IMPORTED_TARGET pet)
pkg_check_modules(ISL REQUIRED IMPORTED_TARGET isl)
endif()
include(src/archive/CMakeLists.txt)
add_library(legality SHARED src/legality.c)
target_link_libraries(legality PUBLIC PkgConfig::ISL PkgConfig::PET)
add_library(codegen SHARED src/codegen.c)
target_link_libraries(codegen PUBLIC PkgConfig::ISL PkgConfig::PET)
add_library(transformations SHARED src/transformations.c)
target_link_libraries(transformations PUBLIC PkgConfig::ISL PkgConfig::PET)
add_library(scops SHARED src/scops.cc)
target_link_libraries(scops PUBLIC PkgConfig::ISL PkgConfig::PET)
include_directories(include)
find_package(Python REQUIRED COMPONENTS Development)
find_package(SWIG) # 4.0 COMPONENTS python)
include (UseSWIG)
add_library(ctadashi SHARED src/ctadashi.cc)
target_link_libraries(ctadashi PUBLIC PkgConfig::ISL PkgConfig::PET legality codegen transformations scops)
set_property(SOURCE src/ctadashi.i
PROPERTY CPLUSPLUS ON
PROPERTY SWIG_INCLUDE_DIRECTORIES )
swig_add_library(ctadashi_py TYPE SHARED LANGUAGE python SOURCES src/ctadashi.i)
swig_link_libraries(ctadashi_py ctadashi Python::Python) # PkgConfig::PET legality codegen transformations)
add_executable(goodbadtest src/goodbadtest.c)
add_executable(tadashi src/tadashi.c)
target_link_libraries(tadashi PUBLIC PkgConfig::ISL PkgConfig::PET legality codegen transformations)
enable_testing()
include(GoogleTest)
add_executable(test_legality tests/cc/test_legality.cc)
target_link_libraries(test_legality PUBLIC PkgConfig::ISL GTest::gtest_main legality)
gtest_discover_tests(test_legality)