-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
58 lines (51 loc) · 2.36 KB
/
Copy pathCMakeLists.txt
File metadata and controls
58 lines (51 loc) · 2.36 KB
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
# MSXFileForge - cross-platform build (Windows / Linux / macOS).
cmake_minimum_required(VERSION 3.16)
project(MSXFileForge CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# --- core library (portable, no GUI deps) ---
add_library(msxcore STATIC
core/disk_image.cpp core/fat12.cpp core/msxfile.cpp core/rom.cpp core/cas.cpp core/util.cpp core/tape.cpp)
target_include_directories(msxcore PUBLIC core)
# --- CLI ---
add_executable(msxforge cli/main.cpp)
target_link_libraries(msxforge PRIVATE msxcore)
# --- dsk2dmk test tool ---
add_executable(dsk2dmk tools/dsk2dmk.cpp)
# --- GUI (Dear ImGui + SDL2 + OpenGL3 + tinyfiledialogs) ---
set(IMGUI ${CMAKE_SOURCE_DIR}/libs/imgui)
add_executable(msxforge-gui
gui/main.cpp
libs/tinyfiledialogs.c
${IMGUI}/imgui.cpp ${IMGUI}/imgui_draw.cpp ${IMGUI}/imgui_tables.cpp ${IMGUI}/imgui_widgets.cpp
${IMGUI}/backends/imgui_impl_sdl2.cpp ${IMGUI}/backends/imgui_impl_opengl3.cpp)
target_include_directories(msxforge-gui PRIVATE ${IMGUI} ${CMAKE_SOURCE_DIR}/libs)
target_compile_definitions(msxforge-gui PRIVATE SDL_MAIN_HANDLED)
target_link_libraries(msxforge-gui PRIVATE msxcore)
find_package(OpenGL REQUIRED)
target_link_libraries(msxforge-gui PRIVATE OpenGL::GL)
if(WIN32)
# Bundled SDL2 (dev headers + import DLL) so Windows devs need nothing installed.
target_include_directories(msxforge-gui PRIVATE ${CMAKE_SOURCE_DIR}/libs/SDL2/include)
# MSVC links the import lib; comdlg32/ole32/shell32/user32 are for tinyfiledialogs.
target_link_libraries(msxforge-gui PRIVATE
${CMAKE_SOURCE_DIR}/libs/SDL2/lib/SDL2.lib
comdlg32 ole32 shell32 user32)
add_custom_command(TARGET msxforge-gui POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/libs/SDL2/lib/SDL2.dll $<TARGET_FILE_DIR:msxforge-gui>)
else()
# Linux / macOS: use the system SDL2 (apt install libsdl2-dev / brew install sdl2).
find_package(SDL2 REQUIRED)
if(TARGET SDL2::SDL2)
target_link_libraries(msxforge-gui PRIVATE SDL2::SDL2) # shared (brew/apt)
elseif(TARGET SDL2::SDL2-static)
target_link_libraries(msxforge-gui PRIVATE SDL2::SDL2-static) # static (cross build)
else()
target_include_directories(msxforge-gui PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(msxforge-gui PRIVATE ${SDL2_LIBRARIES})
endif()
endif()