|
1 | | -<<<<<<< HEAD |
2 | 1 | cmake_minimum_required(VERSION 3.15) |
3 | | -project(ProXPL C) |
4 | | -======= |
5 | | -cmake_minimum_required(VERSION 3.13) |
6 | 2 | project(ProXPL) |
7 | | ->>>>>>> feature/opcode-tests |
8 | 3 |
|
9 | 4 | # Enable C and C++ |
10 | 5 | enable_language(C CXX) |
11 | 6 | set(CMAKE_C_STANDARD 99) |
12 | | -<<<<<<< HEAD |
13 | 7 | set(CMAKE_C_STANDARD_REQUIRED ON) |
| 8 | +set(CMAKE_CXX_STANDARD 17) |
| 9 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
14 | 10 |
|
15 | 11 | if (MSVC) |
16 | 12 | add_compile_options(/W4) |
17 | 13 | else() |
18 | 14 | add_compile_options(-Wall -Wextra) |
19 | 15 | endif() |
20 | 16 |
|
21 | | -# =============================== |
22 | | -# Sources (exclude main.c) |
23 | | -# =============================== |
24 | | -file(GLOB_RECURSE PROX_SOURCES "src/*.c") |
25 | | -list(REMOVE_ITEM PROX_SOURCES "${CMAKE_SOURCE_DIR}/src/main.c") |
26 | | - |
27 | | -# =============================== |
28 | | -# Core library (NO system libs) |
29 | | -# =============================== |
30 | | -add_library(prox_core STATIC ${PROX_SOURCES}) |
31 | | -target_include_directories(prox_core PUBLIC |
32 | | - ${CMAKE_SOURCE_DIR}/include |
33 | | - ${CMAKE_SOURCE_DIR}/src |
34 | | -) |
35 | | - |
36 | | -# =============================== |
37 | | -# Executable (link system libs HERE) |
38 | | -# =============================== |
39 | | -add_executable(prox src/main.c) |
40 | | - |
41 | | -if (UNIX) |
42 | | - target_link_libraries(prox PRIVATE prox_core m) |
43 | | -else() |
44 | | - target_link_libraries(prox PRIVATE prox_core) |
45 | | -endif() |
46 | | - |
47 | | -# =============================== |
48 | | -# Optional components |
49 | | -# =============================== |
50 | | -option(BUILD_TESTS "Build tests" OFF) |
51 | | -option(BUILD_BENCH "Build benchmarks" OFF) |
52 | | - |
53 | | -if (BUILD_TESTS) |
54 | | - enable_testing() |
55 | | - add_subdirectory(tests) |
56 | | -endif() |
57 | | - |
58 | | -if (BUILD_BENCH) |
59 | | - add_subdirectory(tools/bench) |
60 | | -======= |
61 | | -set(CMAKE_CXX_STANDARD 17) |
62 | | -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
63 | | - |
64 | 17 | # --- LLVM Configuration --- |
65 | 18 | find_package(LLVM REQUIRED CONFIG) |
66 | | - |
67 | 19 | message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") |
68 | | -message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") |
69 | | - |
70 | | -# Include LLVM directories |
71 | 20 | include_directories(${LLVM_INCLUDE_DIRS}) |
72 | 21 | add_definitions(${LLVM_DEFINITIONS}) |
73 | | - |
74 | | -# Link directories |
75 | 22 | link_directories(${LLVM_LIBRARY_DIRS}) |
76 | 23 |
|
77 | 24 | # Map generic components to specific libs |
78 | 25 | llvm_map_components_to_libnames(llvm_libs core support executionengine native ipo) |
79 | 26 |
|
80 | | -# --- Project Source --- |
81 | 27 | # Export symbols for Windows DLL |
82 | 28 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) |
83 | 29 |
|
84 | | -# --- Project Source --- |
| 30 | +# --- Include Directories --- |
85 | 31 | include_directories(include) |
| 32 | +include_directories(src) |
86 | 33 |
|
87 | | -# Gather sources (excluding main.c for library) |
| 34 | +# --- Library Sources --- |
88 | 35 | file(GLOB_RECURSE LIB_SOURCES |
89 | 36 | "src/*.c" |
90 | 37 | "src/compiler/*.cpp" |
91 | 38 | ) |
| 39 | +# Exclude main entry point from library |
92 | 40 | list(FILTER LIB_SOURCES EXCLUDE REGEX ".*main\\.c$") |
93 | 41 |
|
94 | | -# --- Shared Library --- |
| 42 | +# --- Core Library --- |
95 | 43 | add_library(proxpl_lib SHARED ${LIB_SOURCES}) |
96 | 44 | target_link_libraries(proxpl_lib PRIVATE ${llvm_libs}) |
97 | 45 |
|
98 | | -# --- Executable --- |
99 | | -add_executable(proxpl src/main.c ${LIB_SOURCES}) |
100 | | - |
101 | | -# Link LLVM and standard libraries |
102 | | -target_link_libraries(proxpl PRIVATE ${llvm_libs}) |
| 46 | +# --- Main Executable --- |
| 47 | +add_executable(proxpl src/main.c) |
| 48 | +target_link_libraries(proxpl PRIVATE proxpl_lib ${llvm_libs}) |
103 | 49 |
|
104 | 50 | if(UNIX) |
105 | 51 | target_link_libraries(proxpl PRIVATE pthread dl z tinfo) |
106 | 52 | target_link_libraries(proxpl_lib PRIVATE pthread dl z tinfo) |
107 | | ->>>>>>> feature/opcode-tests |
| 53 | +endif() |
| 54 | + |
| 55 | +# --- IR Test Executable --- |
| 56 | +add_executable(ir_gen_test tools/ir_gen_test.c) |
| 57 | +target_link_libraries(ir_gen_test PRIVATE proxpl_lib) |
| 58 | + |
| 59 | +# --- LLVM Gen Test Executable --- |
| 60 | +add_executable(llvm_gen_test tools/llvm_gen_test.c) |
| 61 | +target_link_libraries(llvm_gen_test PRIVATE proxpl_lib ${llvm_libs}) |
| 62 | + |
| 63 | +# --- Optional components --- |
| 64 | +option(BUILD_TESTS "Build tests" OFF) |
| 65 | +option(BUILD_BENCH "Build benchmarks" OFF) |
| 66 | + |
| 67 | +if (BUILD_TESTS) |
| 68 | + enable_testing() |
| 69 | + add_subdirectory(tests) |
| 70 | +endif() |
| 71 | + |
| 72 | +if (BUILD_BENCH) |
| 73 | + add_subdirectory(tools/bench) |
108 | 74 | endif() |
0 commit comments