added to aas3
This commit is contained in:
parent
527d2e7346
commit
9ac28aa798
48 changed files with 7134 additions and 0 deletions
59
ass3/simulator_SIC_XE/CMakeLists.txt
Normal file
59
ass3/simulator_SIC_XE/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project(simulator_SIC_XE VERSION 1.0 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Put all build outputs under target/bin
|
||||
set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/target/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIR})
|
||||
|
||||
# Collect all .cpp sources under src/
|
||||
file(GLOB_RECURSE SOURCES "${PROJECT_SOURCE_DIR}/src/*.cpp")
|
||||
|
||||
|
||||
set(MAIN_SRC "${PROJECT_SOURCE_DIR}/src/main.cpp")
|
||||
set(ASSEMBLER_SRC "${PROJECT_SOURCE_DIR}/src/assembler.cpp")
|
||||
list(REMOVE_ITEM SOURCES ${MAIN_SRC} ${ASSEMBLER_SRC})
|
||||
|
||||
if(NOT SOURCES)
|
||||
message(WARNING "No source files found in ${PROJECT_SOURCE_DIR}/src — the build will create an empty library")
|
||||
endif()
|
||||
|
||||
# Build a static library from all sources
|
||||
add_library(simulator_lib STATIC ${SOURCES})
|
||||
target_include_directories(simulator_lib PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
set_target_properties(simulator_lib PROPERTIES OUTPUT_NAME "simulator")
|
||||
|
||||
# If a main.cpp exists, create an executable that links the library.
|
||||
if(EXISTS "${PROJECT_SOURCE_DIR}/src/main.cpp")
|
||||
add_executable(simulator_exec "${PROJECT_SOURCE_DIR}/src/main.cpp")
|
||||
target_link_libraries(simulator_exec PRIVATE simulator_lib)
|
||||
endif()
|
||||
|
||||
if(EXISTS "${PROJECT_SOURCE_DIR}/src/assembler.cpp")
|
||||
add_executable(assembler "${PROJECT_SOURCE_DIR}/src/assembler.cpp")
|
||||
target_link_libraries(assembler PRIVATE simulator_lib)
|
||||
endif()
|
||||
|
||||
message(STATUS "Project: ${PROJECT_NAME}")
|
||||
message(STATUS "Sources found: ${SOURCES}")
|
||||
message(STATUS "Output directory: ${OUTPUT_DIR}")
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/gui/qt/CMakeLists.txt")
|
||||
add_subdirectory(gui/qt)
|
||||
endif()
|
||||
|
||||
# Copy resources directory (if present) to target/res so build output includes them
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/res")
|
||||
add_custom_target(copy_resources
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/target/res
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res ${CMAKE_SOURCE_DIR}/target/res
|
||||
COMMENT "Copying resources from res/ to target/res/"
|
||||
)
|
||||
if(TARGET simulator_exec)
|
||||
add_dependencies(simulator_exec copy_resources)
|
||||
endif()
|
||||
endif()
|
||||
Loading…
Add table
Add a link
Reference in a new issue