-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
51 lines (37 loc) · 1.63 KB
/
CMakeLists.txt
File metadata and controls
51 lines (37 loc) · 1.63 KB
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
# Set the minimum required version of CMake
cmake_minimum_required(VERSION 3.10)
#set(CMAKE_TOOLCHAIN_FILE "$ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake")
# Set the project name and version
project(cnn VERSION 1.0.0)
# Set the C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Set the output directory for executables
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Enable testing
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Include the directories
include_directories("include")
file(GLOB_RECURSE ALL_INCLUDE_DIRS RELATIVE ${CMAKE_SOURCE_DIR} "src/*.hpp" "src/**/*.hpp" "include/**/*.hpp")
foreach(DIR ${ALL_INCLUDE_DIRS})
get_filename_component(DIR_PATH ${DIR} PATH)
include_directories(${DIR_PATH})
endforeach()
# Get a list of all source files in the src directory and its subdirectories
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/**/*.cpp" "include/**/*.cpp")
# Add a library that is built from the source files
add_library(cnn_lib ${SOURCES})
# Link the required libraries to the library
target_link_libraries(cnn_lib PUBLIC)
# Add an executable that is built from main.cpp
add_executable(cnn main.cpp)
# Link the library to the executable
target_link_libraries(cnn PRIVATE cnn_lib)
add_subdirectory(test)
if(EMSCRIPTEN)
# Test doesn't work
set_target_properties(cnn PROPERTIES
LINK_FLAGS "--bind -s WASM=1 -s EXPORTED_FUNCTIONS='[\"_main\", \"_malloc\", \"_free\", \"stringToUTF8\"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\", \"FS\", \"allocate\", \"ALLOC_NORMAL\", \"stringToUTF8\"]'"
)
endif()