diff --git a/CMakeLists.txt b/CMakeLists.txt index e5ec41f..75a5031 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,19 +5,11 @@ VERSION 0.1) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +option(SDL_VENDORED "Use vendored libraries" ON) add_executable(8ChocChip) -#option(BUILD_SHARED_LIBS "Build shared libraries" OFF) - -#file(GLOB ASSETS "${CMAKE_SOURCE_DIR}/assets/*") -# -#foreach(ASSET ${ASSETS}) -# configure_file(${ASSET} ${CMAKE_BINARY_DIR}/assets COPYONLY) -#endforeach() - add_subdirectory(dependencies) add_subdirectory(src) @@ -29,31 +21,11 @@ endif() target_link_libraries(8ChocChip PRIVATE SDL3::SDL3 SDL3_ttf::SDL3_ttf nfd ${libname}++) -# Set the RPATH of the executable to include the directory where SFML libraries are located set_target_properties(8ChocChip PROPERTIES INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN" ) -# Copy DLLs needed for runtime on Windows -if(WIN32) - add_custom_command( - TARGET 8ChocChip - COMMENT "Copy OpenAL DLL" - PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$,x64,x86>/openal32.dll $ - VERBATIM) - - if (BUILD_SHARED_LIBS) - add_custom_command(TARGET 8ChocChip POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - $ - $ - $ - $) - endif() -endif() - # Copy nfd and config++ libraries to the executable directory if (UNIX AND NOT APPLE) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 382d9d7..094cb0e 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -1,4 +1,14 @@ add_subdirectory(nativefiledialog) add_subdirectory(libconfig) -add_subdirectory(sdl) + +if(SDL_VENDORED) + # This assumes you have added SDL as a submodule in vendored/SDL + add_subdirectory(sdl EXCLUDE_FROM_ALL) +else() + # 1. Look for a SDL3 package, + # 2. look for the SDL3-shared component, and + # 3. fail if the shared component cannot be found. + find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared) +endif() + add_subdirectory(sdl_ttf) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 82828df..274ff55 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -125,6 +125,7 @@ int main(int argc, char **argv) { } } + // Do not change, this makes multiple windows not crash for (size_t i = 0; i < windows.size(); ++i) { windows[i]->update(); windows[i]->render();