-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
CMakeLists.txt
102 lines (77 loc) · 3.46 KB
/
CMakeLists.txt
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
cmake_minimum_required(VERSION 3.18)
project(PaxOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
if (WIN32)
message("> Building for Windows")
elseif(APPLE)
message("> Building for macOS")
else()
message("> Building for Linux")
endif()
set(CMAKE_CXX_STANDARD 17)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") # Enable exceptions for CLang
endif()
file(GLOB_RECURSE src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
"./src/*.cpp"
"./src/*.c"
)
file(GLOB_RECURSE ignored_src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
"./src/interface/LovyanGFX/*.cpp"
"./src/interface/LovyanGFX/*.c"
"./src/lib/curl-8.5.0_1-win64-mingw/*.cpp"
"./src/lib/curl-8.5.0_1-win64-mingw/*.c"
)
list(REMOVE_ITEM src ${ignored_src})
file(GLOB gfx_src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
"./src/interface/LovyanGFX/LGFX_SDL.cpp"
"./src/interface/LovyanGFX/lgfx/Fonts/efont/*.c"
"./src/interface/LovyanGFX/lgfx/Fonts/IPA/*.c"
"./src/interface/LovyanGFX/lgfx/utility/*.c"
"./src/interface/LovyanGFX/lgfx/v1/*.cpp"
"./src/interface/LovyanGFX/lgfx/v1/misc/*.cpp"
"./src/interface/LovyanGFX/lgfx/v1/panel/Panel_Device.cpp"
"./src/interface/LovyanGFX/lgfx/v1/panel/Panel_FrameBufferBase.cpp"
"./src/interface/LovyanGFX/lgfx/v1/platforms/sdl/*.cpp"
"./src/interface/LovyanGFX/LGFX_SDL.cpp"
)
add_definitions(-DLGFX_SDL)
add_executable(PaxOS ${src} ${gfx_src})
target_include_directories(PaxOS PUBLIC "src/interface/LovyanGFX")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(SDL2 REQUIRED SDL2)
find_package(CURL REQUIRED) # Add this line to find cURL
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(PaxOS PUBLIC -lpthread ${SDL2_LIBRARIES} CURL::libcurl -lstdc++fs) # Link to cURL
target_link_libraries(PaxOS PRIVATE m)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
target_include_directories(PaxOS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/SDL2-2.28.2/include")
target_include_directories(PaxOS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/curl-8.5.0_1-win64-mingw/include")
target_link_libraries(PaxOS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/SDL2-2.28.2/lib/x64/SDL2main.lib")
target_link_libraries(PaxOS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/SDL2-2.28.2/lib/x64/SDL2.lib")
target_link_libraries(PaxOS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/curl-8.5.0_1-win64-mingw/lib/libcurl.dll.a")
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_package(SDL2 REQUIRED COMPONENTS SDL2)
find_package(CURL REQUIRED) # Add this line to find cURL
target_link_libraries(PaxOS PUBLIC -lpthread ${SDL2_LIBRARIES} CURL::libcurl) # Link to cURL
target_link_libraries(PaxOS PRIVATE SDL2::SDL2)
target_link_libraries(PaxOS PRIVATE m)
ENDIF ()
target_compile_features(PaxOS PUBLIC cxx_std_17)
# COPIER STORAGE/
file(COPY ressources/storage DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# Méthode pour copier un DLL de ressources/ vers l'endroit où se trouve PaxOS.exe
macro(copy_dll DLLName)
file(COPY ressources/dll/${DLLName} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endmacro()
copy_dll(libcurl-x64.dll)
copy_dll(libgcc_s_seh-1.dll)
copy_dll(libstdc++-6.dll)
copy_dll(libwinpthread-1.dll)
if (WIN32)
include_directories(src/lib/dirent-1.23.2/include)
copy_dll(SDL2.dll)
file(GLOB WIN_DLLS resources/*.dll)
message(">> Copying DLLs: ${WIN_DLLS}")
file(COPY ${WIN_DLLS} DESTINATION /)
endif()