-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
63 lines (48 loc) · 2.14 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
cmake_minimum_required(VERSION 3.10)
# set the project name and version
project(Pas2c VERSION 2.1)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(include/nlohmann_json)
add_subdirectory(include/spdlog)
configure_file(src/config.h.in config.h)
# ---------------------------------------------------------------------------------------
# Example of using pre-compiled library
# ---------------------------------------------------------------------------------------
file(GLOB p2c_srcs "src/*.cpp")
# set(p2c_srcs ${main_srcs})
# list(REMOVE_ITEM p2c_srcs ./src/main.cpp)
# list(REMOVE_ITEM main_srcs src/p2c.cpp)
# this is the file I want to exclude / remove from the list
get_filename_component(full_path_test_cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ABSOLUTE)
message("-- Excluded: ${full_path_test_cpp}")
list(REMOVE_ITEM p2c_srcs "${full_path_test_cpp}")
add_executable(p2c ${p2c_srcs})
# add_executable(main ${main_srcs})
# target_link_libraries(main PRIVATE spdlog::spdlog)
target_link_libraries(p2c PRIVATE spdlog::spdlog)
target_link_libraries(p2c PRIVATE nlohmann_json::nlohmann_json)
target_include_directories(p2c PUBLIC
"${PROJECT_BINARY_DIR}"
)
install(TARGETS p2c DESTINATION bin)
# install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
# DESTINATION include
# )
include(CTest)
enable_testing()
add_test(NAME Usage COMMAND p2c)
add_test(NAME Version COMMAND p2c -v)
add_test(NAME Debug COMMAND p2c ../example/gcd.pas -d)
add_test(NAME Output COMMAND p2c ../example/gcd.pas -o test_out.c)
add_test(NAME Log COMMAND p2c ../example/gcd.pas -l test_log.txt)
add_test(NAME quicksort COMMAND p2c ../example/quicksort.pas)
add_test(NAME module_test::const_array_addr COMMAND p2c ../example/module_test/const_array_addr.pas)
add_test(NAME kruskal COMMAND p2c ../example/kruskal.pas)
add_test(NAME record COMMAND p2c ../example/record.pas)
add_test(NAME knapsack COMMAND p2c ../example/knapsack.pas)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)