|
| 1 | +set(TARGET_NAME CodeAstraApp) |
| 2 | +set(EXECUTABLE_NAME CodeAstra) |
| 3 | + |
| 4 | +# Source files |
| 5 | +set(SOURCES |
| 6 | + MainWindow.cpp |
| 7 | + CodeEditor.cpp |
| 8 | + Tree.cpp |
| 9 | + FileManager.cpp |
| 10 | + Syntax.cpp |
| 11 | + SyntaxManager.cpp |
| 12 | +) |
| 13 | + |
| 14 | +# Headers |
| 15 | +set(HEADERS |
| 16 | + ${CMAKE_SOURCE_DIR}/include/MainWindow.h |
| 17 | + ${CMAKE_SOURCE_DIR}/include/CodeEditor.h |
| 18 | + ${CMAKE_SOURCE_DIR}/include/Tree.h |
| 19 | + ${CMAKE_SOURCE_DIR}/include/FileManager.h |
| 20 | + ${CMAKE_SOURCE_DIR}/include/Syntax.h |
| 21 | + ${CMAKE_SOURCE_DIR}/include/SyntaxManager.h |
| 22 | + ${CMAKE_SOURCE_DIR}/include/LineNumberArea.h |
| 23 | +) |
| 24 | + |
| 25 | +# Find yaml-cpp using CMake's package config |
| 26 | +find_package(yaml-cpp REQUIRED) |
| 27 | + |
| 28 | +# Library |
| 29 | +add_library(${TARGET_NAME} ${SOURCES} ${HEADERS}) |
| 30 | +target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) |
| 31 | + |
| 32 | +# Link against the proper target |
| 33 | +target_link_libraries(${TARGET_NAME} PRIVATE Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Widgets yaml-cpp::yaml-cpp) |
| 34 | +set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 35 | + |
| 36 | +# Executable |
| 37 | +add_executable(${EXECUTABLE_NAME} ${CMAKE_SOURCE_DIR}/src/main.cpp) |
| 38 | +target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${TARGET_NAME} Qt6::Core Qt6::Widgets) |
| 39 | +target_include_directories(${EXECUTABLE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) |
| 40 | + |
| 41 | +# Resources |
| 42 | +qt_add_resources(APP_RESOURCES ${CMAKE_SOURCE_DIR}/resources.qrc) |
| 43 | +target_sources(${EXECUTABLE_NAME} PRIVATE ${APP_RESOURCES}) |
| 44 | + |
| 45 | +# OS-specific flags |
| 46 | +if(MSVC) |
| 47 | + target_compile_options(${EXECUTABLE_NAME} PRIVATE /W4 /WX /analyze /sdl /guard:cf) |
| 48 | +elseif(APPLE OR UNIX) |
| 49 | + target_compile_options(${EXECUTABLE_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshadow -Wconversion -Wsign-conversion -fsanitize=address,undefined -fstack-protector) |
| 50 | + target_link_options(${EXECUTABLE_NAME} PRIVATE -fsanitize=address,undefined) |
| 51 | +endif() |
| 52 | + |
| 53 | +# Copy config files |
| 54 | +file(GLOB YAML_FILES "${CMAKE_SOURCE_DIR}/config/*.yaml") |
| 55 | +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/config) |
| 56 | +foreach(YAML_FILE ${YAML_FILES}) |
| 57 | + configure_file(${YAML_FILE} ${CMAKE_BINARY_DIR}/config/ COPYONLY) |
| 58 | +endforeach() |
0 commit comments