summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 64cd30dea120c5935218cf3b8f4492eb242167ae (plain)
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
cmake_minimum_required(VERSION 3.5)
project(risc_vector)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options(-Wall -lstdc++)
add_compile_options(-Wextra -Wpedantic)

# cpp standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_COMPILER "g++")

# header files
include_directories(
	${PROJECT_SOURCE_DIR}/inc
)

# gather source files
file(GLOB_RECURSE SRCS "src/*.cc")
list(REMOVE_ITEM SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc")
#exclude gui files from cli executable
foreach(file ${SRCS})
    if(file MATCHES "${CMAKE_CURRENT_SOURCE_DIR}/src/gui/.*")
        list(REMOVE_ITEM SRCS ${file})
    endif()
endforeach()

# find python3 components
find_package(Python3 COMPONENTS Development REQUIRED)

# binary executable
add_executable(${PROJECT_NAME} ${SRCS} src/main.cc)
target_link_libraries(${PROJECT_NAME} PRIVATE Python3::Python)

find_package(Catch2 REQUIRED)

#gather test files
file(GLOB_RECURSE TESTS "tests/*.cc")

# test executable
add_executable(tests ${SRCS} ${TESTS})
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain PRIVATE Python3::Python)

# test discovery
include(CTest)
include(Catch)
catch_discover_tests(tests)

# ================================
# Qt6 GUI Integration
# ================================
cmake_minimum_required(VERSION 3.16)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# Find Qt6 Components
find_package(Qt6 REQUIRED COMPONENTS Widgets)


# Gather GUI Source Files
file(GLOB_RECURSE GUI_SRCS "src/gui/*.cc")

# Gather GUI Resources
qt_add_resources(GUI_RESOURCES "src/gui/resources.qrc")

# GUI executable
qt_add_executable("${PROJECT_NAME}_gui" ${GUI_SRCS} ${SRCS} ${GUI_RESOURCES})
target_link_libraries("${PROJECT_NAME}_gui" PRIVATE Qt6::Widgets)