@@ -17,6 +17,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1717
1818# Set default build output directories
1919set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} )
20+ set (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} )
2021
2122# Detect operating system
2223if (WIN32 )
@@ -47,31 +48,59 @@ endif()
4748# Set Qt path for find_package
4849set (CMAKE_PREFIX_PATH ${Qt_DIR} )
4950
50- # Find Qt Widgets
51- find_package (Qt${QT_MAJOR_VERSION} COMPONENTS Widgets Test REQUIRED)
51+ # Find Qt components
52+ find_package (Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core Widgets Test )
53+
54+ # Locate yaml-cpp
55+ if (APPLE )
56+ set (yaml-cpp_DIR "/opt/homebrew/Cellar/yaml-cpp/0.8.0/lib/cmake/yaml-cpp" )
57+ endif ()
58+ find_package (yaml-cpp REQUIRED CONFIG)
59+
60+ # Copy YAML files to the build directory (non-macOS case)
61+ set (YAML_SOURCE_DIR ${CMAKE_SOURCE_DIR} /config)
62+ set (YAML_DEST_DIR ${CMAKE_BINARY_DIR} /config)
63+ file (MAKE_DIRECTORY ${YAML_DEST_DIR} )
64+ file (GLOB YAML_FILES "${YAML_SOURCE_DIR} /*.yaml" )
65+
66+ foreach (YAML_FILE ${YAML_FILES} )
67+ file (COPY ${YAML_FILE} DESTINATION ${YAML_DEST_DIR} )
68+ endforeach ()
5269
5370# Create the CodeAstra library
5471add_library (${TARGET_NAME}
5572 src/MainWindow.cpp
5673 src/CodeEditor.cpp
57- src/Syntax.cpp
5874 src/Tree .cpp
5975 src/FileManager.cpp
76+ src/Syntax.cpp
77+ src/SyntaxManager.cpp
6078 include /MainWindow.h
6179 include /CodeEditor.h
62- include /Syntax.h
6380 include /Tree .h
6481 include /LineNumberArea.h
6582 include /FileManager.h
83+ include /SyntaxManager.h
84+ include /Syntax.h
6685)
6786
87+ # Link YAML-CPP to the CodeAstra library
88+ target_link_libraries (${TARGET_NAME} PRIVATE yaml-cpp)
89+
6890# Create the executable for the application
69- add_executable (${EXECUTABLE_NAME}
70- src/main.cpp
71- )
91+ add_executable (${EXECUTABLE_NAME} src/main.cpp)
92+
93+ # Ensure YAML config files are copied into macOS app bundle
94+ # if(APPLE)
95+ # add_custom_command(TARGET ${EXECUTABLE_NAME} POST_BUILD
96+ # COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_BUNDLE_DIR:${EXECUTABLE_NAME}>/Contents/Resources/config"
97+ # COMMAND ${CMAKE_COMMAND} -E copy_directory "${YAML_SOURCE_DIR}" "$<TARGET_BUNDLE_DIR:${EXECUTABLE_NAME}>/Contents/Resources/config"
98+ # COMMENT "Copying YAML config files into macOS app bundle..."
99+ # )
100+ # endif()
72101
73102# Link the main executable with the CodeAstra library and Qt libraries
74- target_link_libraries (${EXECUTABLE_NAME} PRIVATE ${TARGET_NAME} Qt${QT_MAJOR_VERSION} ::Widgets)
103+ target_link_libraries (${EXECUTABLE_NAME} PRIVATE ${TARGET_NAME} Qt${QT_MAJOR_VERSION} ::Core Qt ${QT_MAJOR_VERSION} :: Widgets)
75104
76105# Add the tests subdirectory
77106add_subdirectory (tests)
@@ -85,7 +114,7 @@ if(MSVC)
85114 target_compile_options (${EXECUTABLE_NAME} PRIVATE /W4 /WX)
86115elseif (APPLE )
87116 target_compile_options (${EXECUTABLE_NAME} PRIVATE -Wall -Wextra -pedantic -Werror)
88- set_target_properties (${EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE TRUE )
117+ # set_target_properties(${EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE TRUE)
89118else ()
90119 target_compile_options (${EXECUTABLE_NAME} PRIVATE -Wall -Wextra -pedantic -Werror)
91120endif ()
@@ -103,4 +132,10 @@ set_target_properties(${EXECUTABLE_NAME} PROPERTIES
103132)
104133
105134# Link necessary Qt libraries to CodeAstra library
106- target_link_libraries (${TARGET_NAME} PRIVATE Qt${QT_MAJOR_VERSION} ::Widgets)
135+ target_link_libraries (${TARGET_NAME} PRIVATE Qt${QT_MAJOR_VERSION} ::Core Qt${QT_MAJOR_VERSION} ::Widgets)
136+
137+ # Ensure correct linking of yaml-cpp (macOS)
138+ if (APPLE )
139+ target_include_directories (${EXECUTABLE_NAME} PRIVATE /opt/homebrew/include )
140+ target_link_directories (${EXECUTABLE_NAME} PRIVATE /opt/homebrew/lib)
141+ endif ()
0 commit comments