Skip to content

Commit 59b9dc8

Browse files
committed
Reorganize platform-specific source files and split CMakeLists.txt into multiple directories to avoid future merge conflicts
1 parent 12c29e1 commit 59b9dc8

File tree

12 files changed

+27
-27
lines changed

12 files changed

+27
-27
lines changed

CMakeLists.txt

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,31 @@ endif()
2323
# Auto detect platform if not manually set
2424

2525
if(NOT ESD_WND_PLATFORM)
26+
2627
if(WIN32)
2728
set(PLATFORM "Win32")
2829
elseif(UNIX AND NOT APPLE)
2930
set(PLATFORM "X11")
3031
else()
31-
message(FATAL "Could not auto detect platform, it may be unimplemented")
32+
message(FATAL_ERROR "Could not auto detect platform, it may be unimplemented")
3233
endif()
3334

34-
set(ESD_WND_PLATFORM PLATFORM CACHE STRING "Target Platform" FORCE)
35-
endif()
36-
37-
# Choose platform specific implementation
35+
set(ESD_WND_PLATFORM ${PLATFORM} CACHE STRING "Target Platform" FORCE)
3836

39-
if(ESD_WND_PLATFORM STREQUAL "Win32")
40-
41-
message("Using Win32")
42-
target_sources(eseed_window PRIVATE src/win32/window.cpp)
43-
if(ESD_WND_ENABLE_VULKAN_SUPPORT)
44-
target_sources(eseed_window PRIVATE src/win32/vulkanwindow.cpp)
45-
endif()
37+
endif()
4638

47-
elseif(ESD_WND_PLATFORM STREQUAL "X11")
39+
string(TOLOWER ${ESD_WND_PLATFORM} PLATFORM_DIR_NAME)
4840

49-
message("Using X11")
50-
target_sources(eseed_window PRIVATE src/x11/window.cpp)
51-
find_package(X11 REQUIRED)
52-
target_link_libraries(eseed_window ${X11_LIBRARIES})
53-
if(ESD_WND_ENABLE_VULKAN_SUPPORT)
54-
target_sources(eseed_window PRIVATE src/x11/vulkanwindow.cpp)
55-
endif()
56-
57-
else()
41+
# Choose platform specific implementation
5842

59-
message(FATAL "Unkown platform, it may have been typed incorrectly or is unimplemented")
43+
message("Using ${ESD_WND_PLATFORM}")
6044

45+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/platforms/${PLATFORM_DIR_NAME}")
46+
message(FATAL_ERROR "Unkown platform, it may have been typed incorrectly or is unimplemented")
6147
endif()
6248

49+
add_subdirectory("platforms/${PLATFORM_DIR_NAME}")
50+
6351
# Testing
6452

6553
if(ESD_WND_BUILD_EXAMPLES)

platforms/win32/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
target_sources(eseed_window PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/window.cpp")
4+
if(ESD_WND_ENABLE_VULKAN_SUPPORT)
5+
target_sources(eseed_window PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkanwindow.cpp")
6+
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

platforms/x11/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
target_sources(eseed_window PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/window.cpp")
4+
find_package(X11 REQUIRED)
5+
target_link_libraries(eseed_window ${X11_LIBRARIES})
6+
if(ESD_WND_ENABLE_VULKAN_SUPPORT)
7+
target_sources(eseed_window PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkanwindow.cpp")
8+
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)