From af781666858393cfb72337307a4fbbef935be785 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 26 Jan 2023 23:16:40 +0100 Subject: [PATCH 01/36] Add initial conanfile with all ibrary dependencies --- conanfile.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 conanfile.txt diff --git a/conanfile.txt b/conanfile.txt new file mode 100755 index 0000000..78dee65 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,16 @@ +[requires] +sdl/2.26.1 +sdl_ttf/2.0.18 +sdl_image/2.0.5 +doxygen/1.9.4 + +# conflict resolution +libpng/1.6.39 +zlib/1.2.13 + +# graphviz is not in Conan. Figures, it is a perl program. +# Hope it is optional or can be manually installed if needed. + +[generators] +CMakeDeps +CMakeToolchain From 4b76f45ac20fd0f4bb6421979ce7f174571ad0be Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 26 Jan 2023 23:22:38 +0100 Subject: [PATCH 02/36] Add nooby instructions --- conanfile.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conanfile.txt b/conanfile.txt index 78dee65..9d63e5d 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,3 +1,8 @@ +# standard conan instructions? +# make a new directory next to the source, change into it +# install dependencies with +# conan install ../cerritos --build=missing + [requires] sdl/2.26.1 sdl_ttf/2.0.18 From 4bafa43b7e00353585ae8c5ef59e82bbbb18f55e Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 27 Jan 2023 22:25:17 +0100 Subject: [PATCH 03/36] line end whitespace --- conanfile.txt | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index 9d63e5d..281d34e 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,21 +1,21 @@ -# standard conan instructions? -# make a new directory next to the source, change into it -# install dependencies with -# conan install ../cerritos --build=missing - -[requires] -sdl/2.26.1 -sdl_ttf/2.0.18 -sdl_image/2.0.5 -doxygen/1.9.4 - -# conflict resolution -libpng/1.6.39 -zlib/1.2.13 - -# graphviz is not in Conan. Figures, it is a perl program. -# Hope it is optional or can be manually installed if needed. - -[generators] -CMakeDeps -CMakeToolchain +# standard conan instructions? +# make a new directory next to the source, change into it +# install dependencies with +# conan install ../cerritos --build=missing + +[requires] +sdl/2.26.1 +sdl_ttf/2.0.18 +sdl_image/2.0.5 +doxygen/1.9.4 + +# conflict resolution +libpng/1.6.39 +zlib/1.2.13 + +# graphviz is not in Conan. Figures, it is a perl program. +# Hope it is optional or can be manually installed if needed. + +[generators] +CMakeDeps +CMakeToolchain From 9216d6a9a2010a38cbf8dcc57efa348310a1b778 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 27 Jan 2023 22:28:29 +0100 Subject: [PATCH 04/36] baby steps towards CMake integration --- CMakeLists.txt | 3 +++ conanfile.txt | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05a1254..2051298 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,9 @@ project(cerritos VERSION 0.1.0) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + include(sdl) INCLUDE(FindPkgConfig) #find_package(SDL_ttf REQUIRED) diff --git a/conanfile.txt b/conanfile.txt index 281d34e..4174b06 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,21 +1,24 @@ # standard conan instructions? -# make a new directory next to the source, change into it +# make a new build directory, change into it # install dependencies with -# conan install ../cerritos --build=missing +# conan install --build=missing [requires] sdl/2.26.1 sdl_ttf/2.0.18 sdl_image/2.0.5 +# openal/1.22.2 doxygen/1.9.4 # conflict resolution libpng/1.6.39 zlib/1.2.13 +# libalsa/1.2.7.2 # graphviz is not in Conan. Figures, it is a perl program. # Hope it is optional or can be manually installed if needed. [generators] +cmake CMakeDeps CMakeToolchain From 6d022d03c1da62d017ea217467a4cf971664768d Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 27 Jan 2023 22:54:28 +0100 Subject: [PATCH 05/36] Add macOS prerequisite installation --- BUILDING | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BUILDING b/BUILDING index 0fe4c36..d485c40 100644 --- a/BUILDING +++ b/BUILDING @@ -1,7 +1,10 @@ How to build cerritos 1. Install dependencies -cmake libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev +Linux (package names may vary): +{your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev +macOS: +brew install sdl2 doxygen graphviz sdl2_image sdl2_ttf 2. Create build directory mkdir build From 2e26f48da3fac0448388896141eb7d4016ea3d23 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 27 Jan 2023 23:08:46 +0100 Subject: [PATCH 06/36] Separate SYSTEM includes so common header names like event.h and types.h in this source are found --- src/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24421d4..0841418 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,10 +70,6 @@ install(FILES ) target_include_directories(cerritos PUBLIC - ${SDL2_LIBRARIES} - ${SDL2IMAGE_INCLUDE_DIRS} - ${SDL2TTF_INCLUDE_DIRS} - ${OPENAL_INCLUDE_DIRS} . backend core @@ -85,6 +81,13 @@ target_include_directories(cerritos PUBLIC widgets ) +target_include_directories(cerritos SYSTEM PUBLIC + ${SDL2_LIBRARIES} + ${SDL2IMAGE_INCLUDE_DIRS} + ${SDL2TTF_INCLUDE_DIRS} + ${OPENAL_INCLUDE_DIRS} +) + target_link_libraries(cerritos ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} From 3fad96957f6feda826d3885e100b5b334c697ecb Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 27 Jan 2023 23:15:48 +0100 Subject: [PATCH 07/36] Correct include for apple platforms Not sure whether binreloc is needed there, though. --- src/thirdparty/binreloc/binreloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/thirdparty/binreloc/binreloc.c b/src/thirdparty/binreloc/binreloc.c index 84c22c4..437718c 100644 --- a/src/thirdparty/binreloc/binreloc.c +++ b/src/thirdparty/binreloc/binreloc.c @@ -28,7 +28,11 @@ #include #include #include +#ifdef __APPLE__ +#include +#else #include +#endif #include "binreloc.h" From a9f4b6094b8a51d08c0654310aa1a33eac62f63b Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 27 Jan 2023 23:43:59 +0100 Subject: [PATCH 08/36] Add freealut to macOS and Linux prerequisites --- BUILDING | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILDING b/BUILDING index d485c40..b219f01 100644 --- a/BUILDING +++ b/BUILDING @@ -2,9 +2,9 @@ How to build cerritos 1. Install dependencies Linux (package names may vary): -{your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev +{your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev freealut-dev macOS: -brew install sdl2 doxygen graphviz sdl2_image sdl2_ttf +brew install sdl2 doxygen graphviz sdl2_image sdl2_ttf freealut 2. Create build directory mkdir build From de8f1d058bbd35f7c7a67f3a1c34fe7263ad6a98 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 28 Jan 2023 13:02:51 +0100 Subject: [PATCH 09/36] Only conditionally link stdc++ff Taken mostly from https://gitlab.kitware.com/cmake/cmake/-/issues/17834#note_435285 Constructed from cppreference notes: https://en.cppreference.com/w/cpp/filesystem#Notes We ony handle the GCC case, the problem will go away with time. --- src/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0841418..971b9e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -94,8 +94,7 @@ target_link_libraries(cerritos ${SDL2TTF_LIBRARIES} ${OPENAL_LIBRARIES} alut - stdc++fs - stdc++ + $<$,$,9.1>>:stdc++fs> ) install(TARGETS cerritos From c47392c3f0385392d0b13a8372747707a3430ab5 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 28 Jan 2023 23:10:51 +0100 Subject: [PATCH 10/36] Actually check for OpenAL, use detected library --- CMakeLists.txt | 1 + src/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05a1254..c5bcfa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) include(sdl) INCLUDE(FindPkgConfig) +find_package(OpenAL REQUIRED) #find_package(SDL_ttf REQUIRED) #PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 971b9e5..6afa679 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,14 +85,14 @@ target_include_directories(cerritos SYSTEM PUBLIC ${SDL2_LIBRARIES} ${SDL2IMAGE_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIRS} - ${OPENAL_INCLUDE_DIRS} + ${OPENAL_INCLUDE_DIR} ) target_link_libraries(cerritos ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2TTF_LIBRARIES} - ${OPENAL_LIBRARIES} + ${OPENAL_LIBRARY} alut $<$,$,9.1>>:stdc++fs> ) From 37db31c5f092371dd58e56d3fcdb00ec9e06d0f9 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 28 Jan 2023 23:20:05 +0100 Subject: [PATCH 11/36] Use correct SDL2 libraries Did not cause any error, the TTF and IMAGE includes are identical anyway --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6afa679..ada4b95 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,7 +82,7 @@ target_include_directories(cerritos PUBLIC ) target_include_directories(cerritos SYSTEM PUBLIC - ${SDL2_LIBRARIES} + ${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIR} From 1c6825132ed7f4a47fcb912f88b8110bdd23c638 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 13:21:26 +0100 Subject: [PATCH 12/36] Make conan use optional with USE_CONAN option, default off. Linux and Mac builds work just fine without it, no need to burden them with a huge cache and binaries that do not link to system libraries. --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fc2df0..f5ed325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,11 @@ project(cerritos VERSION 0.1.0) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +option(USE_CONAN "Use Conan" OFF) +if(USE_CONAN) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif(USE_CONAN) include(sdl) INCLUDE(FindPkgConfig) From 81062ad3eb697f1644220786ff9bceedeba74c05 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 18:52:54 +0100 Subject: [PATCH 13/36] Further include corrections Conan, for some reason, puts libary include paths into the argument list with -I, making them collide with our includes. Putting our includes first fixes order problems. Though, it is probably worth considering NOT naming includes "event.h" or "types.h", or force clients to use #include to avoid conflics. --- CMakeLists.txt | 1 + src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5ed325..fbf5174 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ endif(USE_CONAN) include(sdl) INCLUDE(FindPkgConfig) find_package(OpenAL REQUIRED) +#find_package(SDL2_image REQUIRED) #find_package(SDL_ttf REQUIRED) #PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ada4b95..77e6fb0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,7 +69,7 @@ install(FILES DESTINATION include ) -target_include_directories(cerritos PUBLIC +target_include_directories(cerritos BEFORE PUBLIC . backend core From 14ca57e8f4124bb586e54136657a9df203c8df36 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 18:53:28 +0100 Subject: [PATCH 14/36] Allow multiple build directories for different configurations (build_debug, build_conan...) --- .gitignore | 2 +- cmake/sdl.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 47b965b..f55728e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -build +/build* docs/html diff --git a/cmake/sdl.cmake b/cmake/sdl.cmake index 18fb4e1..74275ec 100644 --- a/cmake/sdl.cmake +++ b/cmake/sdl.cmake @@ -1,4 +1,4 @@ find_package(SDL2 REQUIRED) -include_directories(${SDL2_INCLUDE_DIRS}) +include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) From b2d4200ead3e0cf895f7b3b7db2566269866a291 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 21:53:27 +0100 Subject: [PATCH 15/36] Make conan dependencies more flexible and declare doxygen as a tool dependency --- conanfile.txt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index 4174b06..8d53a6c 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -4,16 +4,15 @@ # conan install --build=missing [requires] -sdl/2.26.1 -sdl_ttf/2.0.18 -sdl_image/2.0.5 -# openal/1.22.2 -doxygen/1.9.4 +sdl/[^2.0,>=2.0.14] +sdl_ttf/[^2.0,>=2.0.15] +sdl_image/[^2.0,>=2.0.5] # conflict resolution -libpng/1.6.39 -zlib/1.2.13 -# libalsa/1.2.7.2 +libpng/[^1.6] # odd that this is enough, but no complaining + +[tool_requires] +doxygen/[^1.9,>=1.8] # graphviz is not in Conan. Figures, it is a perl program. # Hope it is optional or can be manually installed if needed. From 40f8650868492edc81a01549592e3eb31dd91bd7 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 21:53:43 +0100 Subject: [PATCH 16/36] Activate shared libraries --- conanfile.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conanfile.txt b/conanfile.txt index 8d53a6c..cb5873d 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -14,6 +14,11 @@ libpng/[^1.6] # odd that this is enough, but no complaining [tool_requires] doxygen/[^1.9,>=1.8] +[options] +sdl:shared=True +sdl_ttf:shared=True +sdl_image:shared=True + # graphviz is not in Conan. Figures, it is a perl program. # Hope it is optional or can be manually installed if needed. From fb68991ddb34ea830e9d1526cc24f0f147b2f2fb Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 22:03:45 +0100 Subject: [PATCH 17/36] Additional fishy zlib conflict resolution --- conanfile.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/conanfile.txt b/conanfile.txt index cb5873d..2fd6a54 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -10,6 +10,7 @@ sdl_image/[^2.0,>=2.0.5] # conflict resolution libpng/[^1.6] # odd that this is enough, but no complaining +zlib/1.2.12 # this one is probably going to break at some point, forcing us to specify narrower versions [tool_requires] doxygen/[^1.9,>=1.8] From 7e39fc922f286a5c6cbd31a4352a7bcae9d7ba37 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 22:15:11 +0100 Subject: [PATCH 18/36] Narrow down doxygen version 1.9.4 causes the conflicts with zlib --- conanfile.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index 2fd6a54..23e6797 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -10,10 +10,9 @@ sdl_image/[^2.0,>=2.0.5] # conflict resolution libpng/[^1.6] # odd that this is enough, but no complaining -zlib/1.2.12 # this one is probably going to break at some point, forcing us to specify narrower versions - [tool_requires] -doxygen/[^1.9,>=1.8] +doxygen/[^1.9,<=1.9.2] +# 1.9.4 locks zlib to a higher version than one of its dependencies, causing irresolvable conflicts here [options] sdl:shared=True From 59dd727c44feb4b89314ecd9664b92c505f3afb9 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 29 Jan 2023 22:26:35 +0100 Subject: [PATCH 19/36] Add DLL/dynlib imports --- conanfile.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conanfile.txt b/conanfile.txt index 23e6797..450edc0 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -26,3 +26,8 @@ sdl_image:shared=True cmake CMakeDeps CMakeToolchain + +[imports] +# copy macOS and Windows dynamic libraries to where they can be found +bin, *.dll -> ./bin +lib, *.dylib* -> ./bin \ No newline at end of file From f4435ec61b255c43b6e0ef9eca6b83b383fbfc89 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 16 Feb 2023 23:41:09 +0100 Subject: [PATCH 20/36] This seems to be the modern unified way to deal with dependencies Just find them with find_package, add them to include and libs with a :: qualified name. Don't forget to declare the lib dependencies PUBLIC so the examles get linked to them as well. --- CMakeLists.txt | 13 +++++-------- src/CMakeLists.txt | 10 +++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbf5174..3f2323e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,14 +17,11 @@ if(USE_CONAN) conan_basic_setup() endif(USE_CONAN) -include(sdl) -INCLUDE(FindPkgConfig) -find_package(OpenAL REQUIRED) -#find_package(SDL2_image REQUIRED) -#find_package(SDL_ttf REQUIRED) -#PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) -PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image) -PKG_SEARCH_MODULE(SDL2TTF REQUIRED SDL2_ttf) +#include(sdl) +find_package(SDL2 REQUIRED) +find_package(SDL2_image REQUIRED) +find_package(SDL2_ttf REQUIRED) +find_package(OpenAL) # The actual cerritos sources add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77e6fb0..8bc3d80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,11 +88,11 @@ target_include_directories(cerritos SYSTEM PUBLIC ${OPENAL_INCLUDE_DIR} ) -target_link_libraries(cerritos - ${SDL2_LIBRARIES} - ${SDL2IMAGE_LIBRARIES} - ${SDL2TTF_LIBRARIES} - ${OPENAL_LIBRARY} +target_link_libraries(cerritos PUBLIC + SDL2::SDL2main + SDL2_image::SDL2_image + SDL2_ttf::SDL2_ttf + OpenAL::OpenAL alut $<$,$,9.1>>:stdc++fs> ) From 5ebd932210fad44ceff75f85cc941c7855aba963 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 17:59:03 +0100 Subject: [PATCH 21/36] macOS compatibility Restore old way for OpenAL library; the new way produces a valid linker line, but then fails to link. Add SDL2::SDL2. Find alut, only if OpenAL was found, do not link with it blindly. --- CMakeLists.txt | 14 ++++++++++++++ src/CMakeLists.txt | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f2323e..f4eb859 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,20 @@ endif(USE_SDL) target_compile_definitions(cerritos PUBLIC BOOST_NO_CXX11_SCOPED_ENUMS) +if(OPENAL_FOUND) +find_library(ALUT_LIBRARY + NAMES + alut + HINTS + lib + lib64 + PATHS + /usr + /usr/local + /opt/local + /sw) +endif(OPENAL_FOUND) + # check if Doxygen is installed find_package(Doxygen) if (DOXYGEN_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8bc3d80..ba2328b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,11 +89,12 @@ target_include_directories(cerritos SYSTEM PUBLIC ) target_link_libraries(cerritos PUBLIC + SDL2::SDL2 SDL2::SDL2main SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf - OpenAL::OpenAL - alut + ${OPENAL_LIBRARY} + ${ALUT_LIBRARY} $<$,$,9.1>>:stdc++fs> ) From 094f19ce5a6cd5a9328e0300497866784cee8654 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 18:13:57 +0100 Subject: [PATCH 22/36] Move find_library further up Somehow, below, it interferes badly with the BUILD_DOC option. --- CMakeLists.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4eb859..895331f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,20 @@ find_package(SDL2_image REQUIRED) find_package(SDL2_ttf REQUIRED) find_package(OpenAL) +if(OPENAL_FOUND) + find_library(ALUT_LIBRARY + NAMES + alut + HINTS + lib + lib64 + PATHS + /usr + /usr/local + /opt/local + /sw) +endif(OPENAL_FOUND) + # The actual cerritos sources add_subdirectory(src) # support libraries in thirdparty @@ -37,20 +51,6 @@ endif(USE_SDL) target_compile_definitions(cerritos PUBLIC BOOST_NO_CXX11_SCOPED_ENUMS) -if(OPENAL_FOUND) -find_library(ALUT_LIBRARY - NAMES - alut - HINTS - lib - lib64 - PATHS - /usr - /usr/local - /opt/local - /sw) -endif(OPENAL_FOUND) - # check if Doxygen is installed find_package(Doxygen) if (DOXYGEN_FOUND) From bde1b585ab5430c227290740edfd52527a08d568 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 18:29:09 +0100 Subject: [PATCH 23/36] Windows does not support shared sdl_ttf so taking that option out --- conanfile.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.txt b/conanfile.txt index 450edc0..2f5b92f 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -16,7 +16,7 @@ doxygen/[^1.9,<=1.9.2] [options] sdl:shared=True -sdl_ttf:shared=True +#sdl_ttf:shared=True sdl_image:shared=True # graphviz is not in Conan. Figures, it is a perl program. From d7b837f036f7bc862d3dfa5038ba6bbfe5c0b53b Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 20:53:35 +0100 Subject: [PATCH 24/36] Conan reworking Switch to cmake_find_package generator so the regular find_package works Remove doxygen from conan; could not immediately get it to work Detect alut include path Make USE_CONAN parameter obsolete, we can just check for the conan include file existence --- CMakeLists.txt | 25 ++++++++++--------------- conanfile.txt | 7 +++++-- src/CMakeLists.txt | 1 + 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 895331f..08f9156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,11 +11,11 @@ project(cerritos VERSION 0.1.0) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -option(USE_CONAN "Use Conan" OFF) -if(USE_CONAN) - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup() -endif(USE_CONAN) +# optionally include conan generated file +set(CONAN_FILE_TO_INCLUDE ${CMAKE_BINARY_DIR}/conan_paths.cmake) +if(EXISTS ${CONAN_FILE_TO_INCLUDE}) + include(${CONAN_FILE_TO_INCLUDE}) +endif() #include(sdl) find_package(SDL2 REQUIRED) @@ -24,17 +24,12 @@ find_package(SDL2_ttf REQUIRED) find_package(OpenAL) if(OPENAL_FOUND) + find_path(ALUT_INCLUDE_DIR + NAMES AL/alut.h) find_library(ALUT_LIBRARY - NAMES - alut - HINTS - lib - lib64 - PATHS - /usr - /usr/local - /opt/local - /sw) + NAMES alut + HINTS lib lib64 + PATH /usr /usr/local /opt/local /sw) endif(OPENAL_FOUND) # The actual cerritos sources diff --git a/conanfile.txt b/conanfile.txt index 2f5b92f..7f83e95 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -11,7 +11,9 @@ sdl_image/[^2.0,>=2.0.5] # conflict resolution libpng/[^1.6] # odd that this is enough, but no complaining [tool_requires] -doxygen/[^1.9,<=1.9.2] + +# the conan version of doxygen does not work the way we exect, so don't use it (for now) +#doxygen/[^1.9,<=1.9.2] # 1.9.4 locks zlib to a higher version than one of its dependencies, causing irresolvable conflicts here [options] @@ -23,7 +25,8 @@ sdl_image:shared=True # Hope it is optional or can be manually installed if needed. [generators] -cmake +cmake_find_package +cmake_paths CMakeDeps CMakeToolchain diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba2328b..25b713b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,6 +86,7 @@ target_include_directories(cerritos SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIR} + ${ALUT_INCLUDE_DIR} ) target_link_libraries(cerritos PUBLIC From 11cd193d07a39abf737b7654f8a731516a9bd318 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 21:06:44 +0100 Subject: [PATCH 25/36] Remove options because NOW they're telling me the options for sdl and sdl_ttf must match... --- conanfile.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index 7f83e95..3e60ee8 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -16,11 +16,6 @@ libpng/[^1.6] # odd that this is enough, but no complaining #doxygen/[^1.9,<=1.9.2] # 1.9.4 locks zlib to a higher version than one of its dependencies, causing irresolvable conflicts here -[options] -sdl:shared=True -#sdl_ttf:shared=True -sdl_image:shared=True - # graphviz is not in Conan. Figures, it is a perl program. # Hope it is optional or can be manually installed if needed. From b10293ab328cd836f8c610d0506ec809faef7a40 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 21:12:27 +0100 Subject: [PATCH 26/36] make OpenAL optional As far as cmake is concerned. Compiling or linking will still fail. --- src/CMakeLists.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 25b713b..3d476a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,8 +85,6 @@ target_include_directories(cerritos SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIRS} - ${OPENAL_INCLUDE_DIR} - ${ALUT_INCLUDE_DIR} ) target_link_libraries(cerritos PUBLIC @@ -94,11 +92,21 @@ target_link_libraries(cerritos PUBLIC SDL2::SDL2main SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf - ${OPENAL_LIBRARY} - ${ALUT_LIBRARY} $<$,$,9.1>>:stdc++fs> ) +if(OPENAL_FOUND) + target_include_directories(cerritos SYSTEM PUBLIC + ${OPENAL_INCLUDE_DIR} + ${ALUT_INCLUDE_DIR} + ) + + target_link_libraries(cerritos PUBLIC + ${OPENAL_LIBRARY} + ${ALUT_LIBRARY} + ) +endif(OPENAL_FOUND) + install(TARGETS cerritos EXPORT cerritos LIBRARY DESTINATION lib From dd039cabae1436812cdad50df00db7ac77de7ca9 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 23:26:57 +0100 Subject: [PATCH 27/36] Define preprocessor symbol if OpenAL is available --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3d476a2..e0c9038 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,6 +96,10 @@ target_link_libraries(cerritos PUBLIC ) if(OPENAL_FOUND) + # having this PUBLIC is probably bad style, but the ALUT definitions + # are required in a header right now... + target_compile_definitions(cerritos PUBLIC USING_OPENAL) + target_include_directories(cerritos SYSTEM PUBLIC ${OPENAL_INCLUDE_DIR} ${ALUT_INCLUDE_DIR} From c8ea7ec1a400271cf4e1b3cc63d3ca3bf9778105 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 17 Feb 2023 23:27:13 +0100 Subject: [PATCH 28/36] Disable sound if OpenAL is unavailable --- src/core/sound.cpp | 10 +++++++++- src/core/sound.h | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/core/sound.cpp b/src/core/sound.cpp index bb3dd52..a05cff5 100644 --- a/src/core/sound.cpp +++ b/src/core/sound.cpp @@ -4,8 +4,10 @@ using namespace cerritos; Sound::Sound(int numSources) { +#ifdef USING_OPENAL alutInit(NULL, NULL); - +#endif + for (int i = 0; i < numSources; i++) { ALuint buffer; m_Buffers.push_back(buffer); @@ -17,15 +19,21 @@ Sound::Sound(int numSources) { } } Sound::~Sound() { +#ifdef USING_OPENAL alutExit(); +#endif } void Sound::LoadSoundFromFile(const char *filename, int index) { +#ifdef USING_OPENAL m_Buffers[index] = alutCreateBufferFromFile(filename); alGenSources((ALuint)1, &m_Sources[index]); alSourcei(m_Sources[index], AL_BUFFER, m_Buffers[index]); +#endif } void Sound::PlaySound(int index) { +#ifdef USING_OPENAL alSourcePlay(m_Sources[index]); +#endif } diff --git a/src/core/sound.h b/src/core/sound.h index 64d83c8..dc3880c 100644 --- a/src/core/sound.h +++ b/src/core/sound.h @@ -1,4 +1,12 @@ +#ifdef USING_OPENAL #include +#else +// rudimentary type replacements +using ALvoid = void; +using ALuint = unsigned int; +// this probably needs competely different abstractions... good enough for just having sound disabled. +#endif + #include "types.h" namespace cerritos { From 78b3301ecb2347f83c5aa8e8ea5a737be2c70676 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 12:50:12 +0100 Subject: [PATCH 29/36] Activate symbol exports on Windows --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f9156..4805b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,9 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# create .lib file on Windows (alternative: export specifically all desired symbols with dllexport, make that a NOP on Unix platforms) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + # set the project name project(cerritos VERSION 0.1.0) From 8ff96223d49b225513e3d36362a3f3feae572234 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 14:10:26 +0100 Subject: [PATCH 30/36] Windows: Copy dll into examples directory Doing this for one of the examples would probably be enough... --- examples/dadsteroids.cmake | 5 +++++ examples/drumTest.cmake | 5 +++++ examples/eventTest.cmake | 4 ++++ examples/fontTest.cmake | 5 +++++ examples/hello.cmake | 4 ++++ examples/pathTest.cmake | 5 +++++ examples/spriteTest.cmake | 4 ++++ 7 files changed, 32 insertions(+) diff --git a/examples/dadsteroids.cmake b/examples/dadsteroids.cmake index 074adb7..a0657bd 100644 --- a/examples/dadsteroids.cmake +++ b/examples/dadsteroids.cmake @@ -10,3 +10,8 @@ target_include_directories(dadsteroids PUBLIC target_link_libraries(dadsteroids cerritos ) + +# copy dll on windows into binary directory +add_custom_command(TARGET dadsteroids POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file diff --git a/examples/drumTest.cmake b/examples/drumTest.cmake index d3c9fe9..2dcf2e0 100644 --- a/examples/drumTest.cmake +++ b/examples/drumTest.cmake @@ -10,3 +10,8 @@ target_include_directories(drumTest PUBLIC target_link_libraries(drumTest cerritos ) + +# copy dll on windows into binary directory +add_custom_command(TARGET drumTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file diff --git a/examples/eventTest.cmake b/examples/eventTest.cmake index ea856a2..938fb57 100644 --- a/examples/eventTest.cmake +++ b/examples/eventTest.cmake @@ -10,3 +10,7 @@ target_link_libraries(eventTest cerritos ) +# copy dll on windows into binary directory +add_custom_command(TARGET eventTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file diff --git a/examples/fontTest.cmake b/examples/fontTest.cmake index 4a3105d..74dc970 100644 --- a/examples/fontTest.cmake +++ b/examples/fontTest.cmake @@ -10,3 +10,8 @@ target_include_directories(fontTest PUBLIC target_link_libraries(fontTest cerritos ) + +# copy dll on windows into binary directory +add_custom_command(TARGET fontTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file diff --git a/examples/hello.cmake b/examples/hello.cmake index 7cd4d9c..4664967 100644 --- a/examples/hello.cmake +++ b/examples/hello.cmake @@ -11,3 +11,7 @@ target_link_libraries(hello cerritos ) +# copy dll on windows into binary directory +add_custom_command(TARGET hello POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file diff --git a/examples/pathTest.cmake b/examples/pathTest.cmake index 59f2ae5..07b6065 100644 --- a/examples/pathTest.cmake +++ b/examples/pathTest.cmake @@ -10,3 +10,8 @@ target_include_directories(pathTest PUBLIC target_link_libraries(pathTest cerritos ) + +# copy dll on windows into binary directory +add_custom_command(TARGET pathTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file diff --git a/examples/spriteTest.cmake b/examples/spriteTest.cmake index 7f31ec5..265fe43 100644 --- a/examples/spriteTest.cmake +++ b/examples/spriteTest.cmake @@ -11,3 +11,7 @@ target_link_libraries(spriteTest cerritos ) +# copy dll on windows into binary directory +add_custom_command(TARGET spriteTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file From 3109aeaa387df17cb957fc5b2c884e0c9b6fef93 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 15:59:40 +0100 Subject: [PATCH 31/36] Non-Windows workaround Disable copy hack for non-windows Even with the hack enabled, add the exe to the source file list so the command does not fail if the DLL list is empty --- examples/dadsteroids.cmake | 8 +++++--- examples/drumTest.cmake | 8 +++++--- examples/eventTest.cmake | 8 +++++--- examples/fontTest.cmake | 8 +++++--- examples/hello.cmake | 8 +++++--- examples/pathTest.cmake | 8 +++++--- examples/spriteTest.cmake | 8 +++++--- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/examples/dadsteroids.cmake b/examples/dadsteroids.cmake index a0657bd..a516825 100644 --- a/examples/dadsteroids.cmake +++ b/examples/dadsteroids.cmake @@ -12,6 +12,8 @@ target_link_libraries(dadsteroids ) # copy dll on windows into binary directory -add_custom_command(TARGET dadsteroids POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET dadsteroids POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif(WIN32) diff --git a/examples/drumTest.cmake b/examples/drumTest.cmake index 2dcf2e0..1687f13 100644 --- a/examples/drumTest.cmake +++ b/examples/drumTest.cmake @@ -12,6 +12,8 @@ target_link_libraries(drumTest ) # copy dll on windows into binary directory -add_custom_command(TARGET drumTest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET drumTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif(WIN32) diff --git a/examples/eventTest.cmake b/examples/eventTest.cmake index 938fb57..9e378b5 100644 --- a/examples/eventTest.cmake +++ b/examples/eventTest.cmake @@ -11,6 +11,8 @@ target_link_libraries(eventTest ) # copy dll on windows into binary directory -add_custom_command(TARGET eventTest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET eventTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ +) +endif(WIN32) diff --git a/examples/fontTest.cmake b/examples/fontTest.cmake index 74dc970..5f14bc3 100644 --- a/examples/fontTest.cmake +++ b/examples/fontTest.cmake @@ -12,6 +12,8 @@ target_link_libraries(fontTest ) # copy dll on windows into binary directory -add_custom_command(TARGET fontTest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET fontTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif(WIN32) diff --git a/examples/hello.cmake b/examples/hello.cmake index 4664967..acde522 100644 --- a/examples/hello.cmake +++ b/examples/hello.cmake @@ -12,6 +12,8 @@ target_link_libraries(hello ) # copy dll on windows into binary directory -add_custom_command(TARGET hello POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET hello POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif(WIN32) diff --git a/examples/pathTest.cmake b/examples/pathTest.cmake index 07b6065..a2b9323 100644 --- a/examples/pathTest.cmake +++ b/examples/pathTest.cmake @@ -12,6 +12,8 @@ target_link_libraries(pathTest ) # copy dll on windows into binary directory -add_custom_command(TARGET pathTest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET pathTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif(WIN32) diff --git a/examples/spriteTest.cmake b/examples/spriteTest.cmake index 265fe43..4c674d4 100644 --- a/examples/spriteTest.cmake +++ b/examples/spriteTest.cmake @@ -12,6 +12,8 @@ target_link_libraries(spriteTest ) # copy dll on windows into binary directory -add_custom_command(TARGET spriteTest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file +if(WIN32) + add_custom_command(TARGET spriteTest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif(WIN32) From 35cb07dff575644c49dabc352388e01416df9b54 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 16:49:04 +0100 Subject: [PATCH 32/36] Add Windows system preparation/build instructions --- BUILDING | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/BUILDING b/BUILDING index b219f01..09a2936 100644 --- a/BUILDING +++ b/BUILDING @@ -1,20 +1,44 @@ How to build cerritos 1. Install dependencies -Linux (package names may vary): -{your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev freealut-dev +Linux (package names may vary), in Terminal: +> {your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev freealut-dev + macOS: -brew install sdl2 doxygen graphviz sdl2_image sdl2_ttf freealut +Get XCode: https://developer.apple.com/support/xcode/ +Get Homebrew via https://brew.sh/; then, in Terminal: +> brew install sdl2 doxygen graphviz sdl2_image sdl2_ttf freealut + +Windows: +Install Visual Studio, for example the 2022 Community Edition: https://visualstudio.microsoft.com/de/vs/community/ +Only the C++ Desktop Development package should be required. +In cmd (all a bit more involved as Windows is lacking some basic tools): +> winget install Git.Git +> winget install cmake +> winget install python +optional: Visual Studio Code editor, not required for building: +> winget install code + +disable python alias via Settings -> Manage App Execution Aliases (use search) +DO NOT install Microsoft store version of python, its path settings seem broken + +In Git Bash (installed with git), install pip (https://pip.pypa.io/en/stable/installation/) +> py -m ensurepip --upgrade +then install conan over pip (https://docs.conan.io/en/2.0/installation.html): +> pip install conan --upgrade 2. Create build directory -mkdir build -cd build +> mkdir build +> cd build + +3: Get Dependencies via Conan (Optional on Linux and macOS if nothing went wrong in step 1, required on Windows): +> conan install .. --build=missing -3. Run cmake -cmake ../ +4. Run cmake +> cmake .. -4. Build! -make +5. Build! +> cmake --build . TODO: Make this document a lot more detailed. From 20fa45993d175ab41c0925e93f6f1cfc2ed7a8e5 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 12:40:52 +0100 Subject: [PATCH 33/36] Disable binreloc on Windows --- src/thirdparty/binreloc/binreloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/thirdparty/binreloc/binreloc.c b/src/thirdparty/binreloc/binreloc.c index 437718c..5e2466d 100644 --- a/src/thirdparty/binreloc/binreloc.c +++ b/src/thirdparty/binreloc/binreloc.c @@ -19,6 +19,8 @@ * 0. You just DO WHAT THE FUCK YOU WANT TO. */ +#ifndef _WIN32 + #include #include #include @@ -756,3 +758,4 @@ br_dirname (const char *path) return result; } +#endif \ No newline at end of file From 29d807c08b671debb147a86dc36697420f1e6f99 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 12:42:48 +0100 Subject: [PATCH 34/36] filesystem::path wstring problem On Windows, filesystem::path is natively using wstrings; however, it has conversions to and from std::string. Use those instead of forcing everyone to deal with string vs wstring. --- examples/dasteroids.cpp | 4 ++-- examples/spriteTest.cpp | 22 +++++++++++----------- src/core/imagemanager.cpp | 2 +- src/core/path.cpp | 6 +++--- src/core/path.h | 8 ++++---- src/core/types.h | 4 ---- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/examples/dasteroids.cpp b/examples/dasteroids.cpp index 8be9dfa..8ef1730 100644 --- a/examples/dasteroids.cpp +++ b/examples/dasteroids.cpp @@ -83,7 +83,7 @@ class Ship : public Sprite { void Fire() { m_Fired = true; m_Bullet = new Bullet(); - m_Bullet->setBackground(_PATH.getFilepath("share", "bullet.bmp")); + m_Bullet->setBackground(_PATH.getFilepath("share", "bullet.bmp").u8string()); m_Bullet->setPosition(this->getPosition()); m_Bullet->setHeading(this->getHeading()); m_Bullet->setSpeed(2.0); @@ -112,7 +112,7 @@ class ftApplication : public Application { m_Ship = new Ship(getMainWindow()->getWindow(), 200,200, 40, 40, 1 ); - m_Ship->setBackground(_PATH.getFilepath("share", "dadship.png")); + m_Ship->setBackground(_PATH.getFilepath("share", "dadship.png").u8string()); m_Ship->setPosition(200,200); diff --git a/examples/spriteTest.cpp b/examples/spriteTest.cpp index a8aa8aa..fb9c700 100644 --- a/examples/spriteTest.cpp +++ b/examples/spriteTest.cpp @@ -108,19 +108,19 @@ int main( int argc, char* args[] ) { theSprite = new Sprite(theWindow->getWindow(), 0, 0, 64, 64, 10); theOtherSprite = new Sprite(theWindow->getWindow(), 250, 250, 64, 64, 1); - List dancing = {_PATH.getFilepath("share", "boimlerdance00.bmp"), - _PATH.getFilepath("share", "boimlerdance01.bmp"), - _PATH.getFilepath("share", "boimlerdance02.bmp"), - _PATH.getFilepath("share", "boimlerdance01.bmp") }; + List dancing = {_PATH.getFilepath("share", "boimlerdance00.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance01.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance02.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance01.bmp").u8string() }; - List walking = {_PATH.getFilepath("share", "boimlerdance10.bmp"), - _PATH.getFilepath("share", "boimlerdance11.bmp"), - _PATH.getFilepath("share", "boimlerdance12.bmp"), - _PATH.getFilepath("share", "boimlerdance13.bmp"), - _PATH.getFilepath("share", "boimlerdance14.bmp"), - _PATH.getFilepath("share", "boimlerdance12.bmp") }; + List walking = {_PATH.getFilepath("share", "boimlerdance10.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance11.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance12.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance13.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance14.bmp").u8string(), + _PATH.getFilepath("share", "boimlerdance12.bmp").u8string() }; - List ship = {_PATH.getFilepath("share", "spaceship.bmp")}; + List ship = {_PATH.getFilepath("share", "spaceship.bmp").u8string()}; theSprite->addSpriteMode(0, dancing); theSprite->setDefaultMode(1); diff --git a/src/core/imagemanager.cpp b/src/core/imagemanager.cpp index 06f2080..9a9e821 100644 --- a/src/core/imagemanager.cpp +++ b/src/core/imagemanager.cpp @@ -54,7 +54,7 @@ Surface* ImageManager::loadFromFile(const char* filename) { } Surface* ImageManager::loadPath(String searchpath, String filename) { - return loadFromFile(_PATH.getFilepath(searchpath, filename) ); + return loadFromFile(_PATH.getFilepath(searchpath, filename).u8string() ); } Surface* ImageManager::loadFromFile(String filename) { diff --git a/src/core/path.cpp b/src/core/path.cpp index 4f8ece0..9e817b9 100644 --- a/src/core/path.cpp +++ b/src/core/path.cpp @@ -68,7 +68,7 @@ void Path::m_initialize(const char* programName, bool overwrite) { return; if(programName != NULL) { - p_name = Dirpath(programName).filename(); + p_name = Dirpath(programName).filename().u8string(); } else { p_name = getProgramNameFile(); } @@ -184,7 +184,7 @@ void Path::setAssetDir(String newAssetdir) { } String Path::getProgramNameFile() { - return String(m_ProgramName.filename() ); + return m_ProgramName.filename().u8string(); } void Path::setProgramName(String programName) { @@ -204,7 +204,7 @@ void Path::showPaths() { const Dirpath Path::getFilepath(String searchpath, String filename, bool useSysDirs) { if (m_AllPaths.has_key(searchpath)) { // Found the path - return String( (m_AllPaths[searchpath] / filename).c_str() ); + return (m_AllPaths[searchpath] / filename).u8string(); } return String(""); diff --git a/src/core/path.h b/src/core/path.h index 0f7ca3d..835e2a8 100644 --- a/src/core/path.h +++ b/src/core/path.h @@ -78,17 +78,17 @@ class Path { const Dirpath getFilepath(String searchpath, String filename, bool useSysDirs=false); /// Overloaded member for convenience. - String getFilepath(const char* searchpath, const char* filename, bool useSysDirs=false) { + Dirpath getFilepath(const char* searchpath, const char* filename, bool useSysDirs=false) { return getFilepath(String(searchpath), String(filename), useSysDirs); }; /// Overloaded member for convenience. - String getFilepath(String searchpath, const char* filename, bool useSysDirs=false) { + Dirpath getFilepath(String searchpath, const char* filename, bool useSysDirs=false) { return getFilepath(searchpath, String(filename), useSysDirs); }; /// Overloaded member for convenience. - String getFilepath(const char* searchpath, String filename, bool useSysDirs=false) { + Dirpath getFilepath(const char* searchpath, String filename, bool useSysDirs=false) { return getFilepath(String(searchpath), filename, useSysDirs ); }; @@ -108,7 +108,7 @@ class Path { String getAssetDir() { return m_AssetDir; }; - String getAppPath() { return m_AppPath; }; + String getAppPath() { return m_AppPath.u8string(); }; void setPrefix(const char* prefix) { setPrefix(String(prefix) ); diff --git a/src/core/types.h b/src/core/types.h index c1e5317..e51d256 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -94,11 +94,7 @@ typedef enum { * typedefs and defines that hopefully provide reasonable cross-platform * strings from the C++ standard library */ -#ifdef _WIN32 -typedef std::wstring String; -#else typedef std::string String; -#endif typedef std::filesystem::path Dirpath; From dd2e92a3bb26430f1d471459821bc88d2577bf08 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 18 Feb 2023 13:54:25 +0100 Subject: [PATCH 35/36] Move chaining constructors to cpp file I can't explain it, but on Windows with VC++, having them in the header causes linker failures with cMainWindow's vtables. Could be a compiler bug. --- src/widgets/mainwindow.cpp | 7 +++++++ src/widgets/mainwindow.h | 9 +++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/widgets/mainwindow.cpp b/src/widgets/mainwindow.cpp index 504d996..35bfe91 100644 --- a/src/widgets/mainwindow.cpp +++ b/src/widgets/mainwindow.cpp @@ -67,6 +67,13 @@ void cMainWindow::Move() { #endif // USING_SDL } +cMainWindow::cMainWindow(CER_WindowFlags winFlags) : + cMainWindow("Cerritos Window", 800, 600, CER_WindowPos_Centered, CER_WindowPos_Centered, winFlags) { }; +cMainWindow::cMainWindow(String title, CER_WindowFlags winFlags) : + cMainWindow(title, 800, 600, CER_WindowPos_Centered, CER_WindowPos_Centered, winFlags) { }; +cMainWindow::cMainWindow(String title, int width, int height, CER_WindowFlags winFlags) : + cMainWindow(title, 800, 600, CER_WindowPos_Centered, CER_WindowPos_Centered, winFlags) { }; + cMainWindow::cMainWindow(String title, int width, int height, int posx, int posy, CER_WindowFlags winFlags) : cWidget(NULL), m_Title(title), m_Size(width, height), m_Position(posx, posy), diff --git a/src/widgets/mainwindow.h b/src/widgets/mainwindow.h index d694cc3..d08d014 100644 --- a/src/widgets/mainwindow.h +++ b/src/widgets/mainwindow.h @@ -64,12 +64,9 @@ class cMainWindow : public cerritos::cWidget { // Constructors //cMainWindow(); - cMainWindow(CER_WindowFlags winFlags=CER_Shown) : - cMainWindow("Cerritos Window", 800, 600, CER_WindowPos_Centered, CER_WindowPos_Centered, winFlags) { }; - cMainWindow(String title, CER_WindowFlags winFlags=CER_Shown) : - cMainWindow(title, 800, 600, CER_WindowPos_Centered, CER_WindowPos_Centered, winFlags) { }; - cMainWindow(String title, int width, int height, CER_WindowFlags winFlags=CER_Shown) : - cMainWindow(title, 800, 600, CER_WindowPos_Centered, CER_WindowPos_Centered, winFlags) { }; + cMainWindow(CER_WindowFlags winFlags=CER_Shown); + cMainWindow(String title, CER_WindowFlags winFlags=CER_Shown); + cMainWindow(String title, int width, int height, CER_WindowFlags winFlags=CER_Shown); cMainWindow(String title, int width, int height, int posx, int posy, CER_WindowFlags winFlags=CER_Shown); virtual ~cMainWindow(); From c38b16b9467f9ec5e4a920398dc74dd18e8d108d Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Mon, 27 Feb 2023 21:57:40 +0100 Subject: [PATCH 36/36] More Windows disabling Some MinGW and Cygwin compiler configurations do not define _WIN32. --- src/thirdparty/binreloc/binreloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thirdparty/binreloc/binreloc.c b/src/thirdparty/binreloc/binreloc.c index 5e2466d..a56b9dc 100644 --- a/src/thirdparty/binreloc/binreloc.c +++ b/src/thirdparty/binreloc/binreloc.c @@ -19,7 +19,7 @@ * 0. You just DO WHAT THE FUCK YOU WANT TO. */ -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) #include #include