-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
74 lines (60 loc) · 1.9 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
# cmake_minimum_required(VERSION 3.0)
# project(neural_network)
# find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
# find_package(PythonLibs 3.0 REQUIRED)
# include_directories(
# include
# ${PYTHON3_INCLUDE_DIRS} ${NumPy_INCLUDE_DIRS})
# # add_executable(three_layer src/3L/main.cpp)
# # target_link_libraries(three_layer)
# # add_executable(four_layer src/4L/main.cpp)
# # target_link_libraries(four_layer)
# add_executable(five_layer src/5L/main.cpp)
# target_link_libraries(five_layer ${PYTHON_LIBRARIES})
# CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project("example" LANGUAGES CXX)
# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()
# find python libraries
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
find_package(PythonLibs 3.0 REQUIRED)
include_directories(
include
${PYTHON3_INCLUDE_DIRS}
${NumPy_INCLUDE_DIRS}
)
# populate matplotlib repository
include(FetchContent)
FetchContent_Declare(
matplotlib
GIT_REPOSITORY https://github.com/lava/matplotlib-cpp.git
GIT_TAG f23347fca25219d1c42cbb91608b5556814bf572
)
FetchContent_GetProperties(matplotlib)
if(NOT matplotlib_POPULATED)
FetchContent_Populate(matplotlib)
endif()
include_directories(SYSTEM ${matplotlib_SOURCE_DIR})
# add executable
add_executable(5L src/5L/main.cpp)
add_executable(4L src/4L/main.cpp)
add_executable(3L src/3L/main.cpp)
# link python and numpy
target_link_libraries(5L
PRIVATE
${PYTHON_LIBRARIES}
Python3::NumPy
)
target_link_libraries(4L
PRIVATE
${PYTHON_LIBRARIES}
Python3::NumPy
)
target_link_libraries(3L
PRIVATE
${PYTHON_LIBRARIES}
Python3::NumPy
)