From af781666858393cfb72337307a4fbbef935be785 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 26 Jan 2023 23:16:40 +0100 Subject: [PATCH 01/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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 f39e72bb22c29d1d02626bae6b72aee40f2a763f Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 23 Feb 2023 21:44:30 +0100 Subject: [PATCH 33/54] Handle diamond conflicts differently Looks like "just give me the latest transitive dependency you have that still looks compatible" is a more robust approach. --- conanfile.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index 3e60ee8..d6aff4f 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -4,12 +4,15 @@ # conan install --build=missing [requires] -sdl/[^2.0,>=2.0.14] +sdl/[^2.0,>=2.26.1] sdl_ttf/[^2.0,>=2.0.15] sdl_image/[^2.0,>=2.0.5] -# conflict resolution -libpng/[^1.6] # odd that this is enough, but no complaining +# conflict resolution; apparently it is enough to just state the conflicting transitive +# dependencies with a broad version specification. +libpng/[^1] +xz_utils/[^5] + [tool_requires] # the conan version of doxygen does not work the way we exect, so don't use it (for now) From 2618a1f824702ef8d6407c5efc2e03b0c6641afe Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 23 Feb 2023 21:45:45 +0100 Subject: [PATCH 34/54] Add VirtualBuildEnv required for sane cross compilation --- conanfile.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/conanfile.txt b/conanfile.txt index d6aff4f..872a912 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -27,6 +27,7 @@ cmake_find_package cmake_paths CMakeDeps CMakeToolchain +VirtualBuildEnv [imports] # copy macOS and Windows dynamic libraries to where they can be found From 4d4d627cd045f9e5717a45f79ca5f30987ce090c Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 23 Feb 2023 21:46:58 +0100 Subject: [PATCH 35/54] Add USE_OPENAL switch default to ON. Can be turned off for cross compilation where we would not want a native version to be picked up --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4805b38..b662659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,11 +20,18 @@ if(EXISTS ${CONAN_FILE_TO_INCLUDE}) include(${CONAN_FILE_TO_INCLUDE}) endif() +# Build documentation +option(BUILD_DOC "Build documentation" ON) +option(USE_SDL "Use SDL" ON) +option(USE_OPENAL "Use OpenAL" ON) + #include(sdl) find_package(SDL2 REQUIRED) find_package(SDL2_image REQUIRED) find_package(SDL2_ttf REQUIRED) -find_package(OpenAL) +if(USE_OPENAL) + find_package(OpenAL) +endif(USE_OPENAL) if(OPENAL_FOUND) find_path(ALUT_INCLUDE_DIR @@ -39,10 +46,6 @@ endif(OPENAL_FOUND) add_subdirectory(src) # support libraries in thirdparty -# Build documentation -option(BUILD_DOC "Build documentation" ON) -option(USE_SDL "Use SDL" ON) - if(USE_SDL) target_compile_definitions(cerritos PUBLIC USING_SDL) endif(USE_SDL) From 3209e046b358e4270a57f8b3a018bb0ddd3ed3f7 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 23 Feb 2023 22:18:05 +0100 Subject: [PATCH 36/54] Disable cmake toolchain generation Using it just seems to mess things up. --- conanfile.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/conanfile.txt b/conanfile.txt index 872a912..a28b67b 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -26,7 +26,6 @@ xz_utils/[^5] cmake_find_package cmake_paths CMakeDeps -CMakeToolchain VirtualBuildEnv [imports] From 17faeb6d69738924d21dc074a4e8f146b6555b04 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Thu, 23 Feb 2023 22:33:03 +0100 Subject: [PATCH 37/54] Add USE_CONAN variable to check later We may, later, need to distinguish under which names dependencies are available. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b662659..d4e3b22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,10 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) # optionally include conan generated file set(CONAN_FILE_TO_INCLUDE ${CMAKE_BINARY_DIR}/conan_paths.cmake) +set(USE_CONAN OFF) if(EXISTS ${CONAN_FILE_TO_INCLUDE}) include(${CONAN_FILE_TO_INCLUDE}) + set(USE_CONAN ON) endif() # Build documentation From c1935b1ad5ca96d814ade9ddaf67da7e8ddce015 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 24 Feb 2023 00:05:11 +0100 Subject: [PATCH 38/54] Add cross compilation script --- BUILDING | 3 + crosscompile/linux_to_windows.sh | 96 ++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100755 crosscompile/linux_to_windows.sh diff --git a/BUILDING b/BUILDING index 09a2936..252c4ec 100644 --- a/BUILDING +++ b/BUILDING @@ -27,6 +27,9 @@ In Git Bash (installed with git), install pip (https://pip.pypa.io/en/stable/ins then install conan over pip (https://docs.conan.io/en/2.0/installation.html): > pip install conan --upgrade +Cross Compilation: +Look at the scripts and documentation in the crosscompile directory + 2. Create build directory > mkdir build > cd build diff --git a/crosscompile/linux_to_windows.sh b/crosscompile/linux_to_windows.sh new file mode 100755 index 0000000..0871489 --- /dev/null +++ b/crosscompile/linux_to_windows.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# Usage: linux_to_windows.sh +# call from your build directory. So, for example, you would do starting from the main source: +# > mkdir build_win64 +# > cd build_win64 +# > ../crosscompile/linux_to_windows.sh + +# Prerequisites (aside from conan and cmake): +# Install mingw-w64 +# Ubunutu: sudo apt-get install g++-mingw-w64 gcc-mingw-w64 +# Arch: sudo pacman -S mingw-w64-crt + +# Documentation this is based on: +# https://docs.conan.io/1/systems_cross_building/cross_building.html#cross-building-examples-profiles +# https://docs.conan.io/2.0/tutorial/consuming_packages/cross_building_with_conan.html +# https://www.aroeira.io/post/cross-compile/ + +set -x + +SOURCE_PATH=$(dirname $(dirname $0)) +shift + +# see if we need to update the conan configuration +if test "${SOURCE_PATH}"/conanfile.txt -nt conan_paths.cmake || test "$0" -nt conan_paths.cmake; then + rm -f CMakeCache.txt conan.lock conan_paths.cmake + + # determine mingw version + + # generate profile data + toolchain=/usr/x86_64-w64-mingw32 # Maybe adjust this path + target_host=x86_64-w64-mingw32 + cc_compiler=gcc + cxx_compiler=g++ + + # somehow, one has to set this manually to a cross compiler, or some conan builds fail + export CC=$target_host-$cc_compiler + export CXX=$target_host-$cxx_compiler + + # horrible way to fetch conan compliant version from mingw. + # conan expects at most two versions segments, no trailing zero. So 1, 1.1, 2, 2.1, 2.2 + # # to here: line with version at the end + # # to here: just the version, bits before cut off + # # to here: cut off any more than two version segments + # # cut off trailing 0 + compiler_version=$($target_host-$cc_compiler --version | head -n 1 | sed -e 's/.* //g' | sed -E 's/([^\.]*)\.([^\.]*)\..*/\1.\2/' | sed -e 's/^{0}/\0/') + + # compose profle + cat > win64.profile << EOF + toolchain=$toolchain + target_host=$target_host + cc_compiler=$cc_compiler + cxx_compiler=$cxx_compiler + + [buildenv] + CONAN_CMAKE_FIND_ROOT_PATH=\$toolchain # Optional, for CMake to find things in that folder + CONAN_CMAKE_SYSROOT=\$toolchain # Optional, if we want to define sysroot + CHOST=\$target_host + AR=\$target_host-ar + AS=\$target_host-as + RANLIB=\$target_host-ranlib + CC=\$target_host-\$cc_compiler + CXX=\$target_host-\$cxx_compiler + STRIP=\$target_host-strip + RC=\$target_host-windres + + [settings] + # We are cross-building to Windows + os=Windows + arch=x86_64 + compiler=gcc + + compiler.version=$compiler_version + #compiler.version=12 + compiler.libcxx=libstdc++11 + build_type=Release +EOF + + #conan install "${SOURCE_PATH}" -pr:b=default -pr:h=win64.profile --no-imports || exit $? + + # use the generated profile to make conan install the correct cross compilation libraries + #conan install "${SOURCE_PATH}" --build=missing -s:b os_build=Linux -pr=win64.profile || exit $? + conan install "${SOURCE_PATH}" --build=missing -pr:b=default -pr:h=win64.profile || exit $? +fi + +# use the conan provided build environment from here on +source ./conanbuild.sh || exit $? + +# build configuration with CMAKE. All further arguments are passed to it +# USE_OPENAL=OFF is required because we can't install OpenAL over conan and +# cmake would pick up a native version, if available +cmake -DUSE_OPENAL=OFF "${SOURCE_PATH}" "$@" || exit $? + +# build with maximum paralellism +cmake --build . -j $(( `nproc` + 1 )) || exit $? + From 80c3dd9984a32bb0c3e2c996c7969c5c7fe0a527 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 24 Feb 2023 23:21:54 +0100 Subject: [PATCH 39/54] Make sure we install conan < 2.0 --- BUILDING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING b/BUILDING index 252c4ec..14e9270 100644 --- a/BUILDING +++ b/BUILDING @@ -25,7 +25,7 @@ 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 +> pip install 'conan<2.0' --upgrade Cross Compilation: Look at the scripts and documentation in the crosscompile directory From 19076eb2a4ba131e195062eddaa701ee94c38372 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Fri, 24 Feb 2023 23:22:27 +0100 Subject: [PATCH 40/54] Add WIP documentation on how to build in wine No working solution found yet --- crosscompile/wine.md | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 crosscompile/wine.md diff --git a/crosscompile/wine.md b/crosscompile/wine.md new file mode 100644 index 0000000..9190a3c --- /dev/null +++ b/crosscompile/wine.md @@ -0,0 +1,68 @@ +# How to compile for Windows under Wine + +Note: This is work in progress and does not yet work to the end. It maybe never will. + +## Setup + +Basically, follow the instructions for native Windows builds. +However, winget does not work in wine, so you have to install everything by hand or with winetricks. +* Git: Not required, just use git and your favorite shell from the Linux side +* VS Code: Not required + +* CMake: + * Comfortable: + > winetricks cmake + * Manual: + https://cmake.org/download/ + + Pick the .msi installer + + + Choose 'Add CMake to system PATH' (current user or all users should not matter) + +* Python: https://www.python.org/downloads/windows/ + + Pick the 64 bit zip (embeddable) archive + + Unzip to your Windows C drive (~/.wine/drive_c), directory Python + + Unzip the contained python*.zip directly there, too + + Add that folder to the Windows search path: execute + > wine regedit + + navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, + edit the value PATH; append ';C:\Python;C:\Python\Scripts;C:\Program Files\CodeBlocks\MinGW\bin'. + (the MinGW bit is for code::blocks later) + +* Pip: Via the get-pip.py method: https://pip.pypa.io/en/stable/installation/#get-pip-py + > wget https://bootstrap.pypa.io/get-pip.py + > wine python get-pip.py + + This installs the pip module in C:\Python\Lib\site-packages... where it is not found. + Setting the PTHONPATH by any means to include it did not work for me (advice welcome), + so I ended up just doing in ~/.wine/drive_c/Python: + > ln -s Lib/site-packages/* . + +* Conan: easy peasy if everything above went right: + > wine pip install 'conan<2.0' + + Followed by another + > ln -s Lib/site-packages/* . + + in ~/.wine/drive_c/Python. + +And then you are stuck. + +## The following steps were tried, too + +* Visual Studio Build Tools: + > winetricks vstools2019 -q + + Result: Could not install. + +* Instead of the big Visual Studio, you can try Code::Blocks with mingw. Download from https://www.codeblocks.org/downloads/binaries/#imagesoswindows48pnglogo-microsoft-windows + Pick the *mingw-setup.exe variant + > wine ./codeblocks-20.03mingw-setup.exe + + Result: Installs fine, runs fine, autodetected by conan. However, 'conan install' then fails to build everything. From 6e1c291c6efae8c44f7c96739fbbac8080e31974 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 11:20:31 +0100 Subject: [PATCH 41/54] Make versions conan 2.0 compatible --- conanfile.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index a28b67b..00fd08e 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -4,9 +4,9 @@ # conan install --build=missing [requires] -sdl/[^2.0,>=2.26.1] -sdl_ttf/[^2.0,>=2.0.15] -sdl_image/[^2.0,>=2.0.5] +sdl/[^2.0 >=2.26.1] +sdl_ttf/[^2.0 >=2.0.15] +sdl_image/[^2.0 >=2.0.5] # conflict resolution; apparently it is enough to just state the conflicting transitive # dependencies with a broad version specification. From 403e92d820a936e3c1d3ab32af3cb4df89431a03 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 11:20:51 +0100 Subject: [PATCH 42/54] Remove iconv dependency from SDL --- conanfile.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conanfile.txt b/conanfile.txt index 00fd08e..061b886 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -13,6 +13,11 @@ sdl_image/[^2.0 >=2.0.5] libpng/[^1] xz_utils/[^5] +[options] +# we don't need that, it is huge and breaks compilation on Wine +sdl:iconv=False +# sdl_image:with_libjpeg=False + [tool_requires] # the conan version of doxygen does not work the way we exect, so don't use it (for now) From 97c6dd69f6b96d93ce767e337ca3d69837c17708 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 11:43:13 +0100 Subject: [PATCH 43/54] Remove futule attempts to fix wine compilation --- conanfile.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/conanfile.txt b/conanfile.txt index 061b886..2f00549 100755 --- a/conanfile.txt +++ b/conanfile.txt @@ -16,7 +16,6 @@ xz_utils/[^5] [options] # we don't need that, it is huge and breaks compilation on Wine sdl:iconv=False -# sdl_image:with_libjpeg=False [tool_requires] From 8e441038890c00d13239a74dcd25314073a91216 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 16:29:03 +0100 Subject: [PATCH 44/54] Convert conan config to conanfile.py We are going to need it in a minute --- conanfile.py | 36 ++++++++++++++++++++++++++++++++++++ conanfile.txt | 38 -------------------------------------- 2 files changed, 36 insertions(+), 38 deletions(-) create mode 100755 conanfile.py delete mode 100755 conanfile.txt diff --git a/conanfile.py b/conanfile.py new file mode 100755 index 0000000..0fe9a37 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,36 @@ +# standard conan instructions: +# make a new build directory, change into it +# install dependencies with +# conan install --build=missing + +from conans import ConanFile, CMake + +class CerritosConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + + generators = \ + "cmake_find_package", \ + "cmake_paths", \ + "CMakeDeps", \ + "VirtualBuildEnv" + + requires = \ + "sdl/[^2.0 >=2.26.1]", \ + "sdl_ttf/[^2.0 >=2.0.15]", \ + "sdl_image/[^2.0 >=2.0.5]", \ + "libpng/[^1]", \ + "xz_utils/[^5]" + + # libpng and xy_utils are for conflict resolution; apparently it is enough to just state the conflicting transitive + # dependencies with a broad version specification. + + + # graphviz is not in Conan. Figures, it is a perl program. + # Hope it is optional or can be manually installed if needed. + + def configure(self): + self.options["sdl"].iconv = False + + def imports(self): + self.copy("*.dll", dst="bin", src="bin") + self.copy("*.dylib", dst="bin", src="lib") diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100755 index 2f00549..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,38 +0,0 @@ -# standard conan instructions? -# make a new build directory, change into it -# install dependencies with -# conan install --build=missing - -[requires] -sdl/[^2.0 >=2.26.1] -sdl_ttf/[^2.0 >=2.0.15] -sdl_image/[^2.0 >=2.0.5] - -# conflict resolution; apparently it is enough to just state the conflicting transitive -# dependencies with a broad version specification. -libpng/[^1] -xz_utils/[^5] - -[options] -# we don't need that, it is huge and breaks compilation on Wine -sdl:iconv=False - -[tool_requires] - -# 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 - -# graphviz is not in Conan. Figures, it is a perl program. -# Hope it is optional or can be manually installed if needed. - -[generators] -cmake_find_package -cmake_paths -CMakeDeps -VirtualBuildEnv - -[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 ab2a65ce5ba81f2f7ee30850f86abcbb626fc6ef Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 16:29:46 +0100 Subject: [PATCH 45/54] Keep sdl.iconv on macOS It's not supported to turn that off here --- conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 0fe9a37..4f85c74 100755 --- a/conanfile.py +++ b/conanfile.py @@ -29,7 +29,8 @@ class CerritosConan(ConanFile): # Hope it is optional or can be manually installed if needed. def configure(self): - self.options["sdl"].iconv = False + if self.settings.os != "Macos": + self.options["sdl"].iconv = False def imports(self): self.copy("*.dll", dst="bin", src="bin") From 08509bf9efd6156ce3bd1660bcd95370516919e3 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 17:36:19 +0100 Subject: [PATCH 46/54] Really pass all parameters to CMake --- crosscompile/linux_to_windows.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/crosscompile/linux_to_windows.sh b/crosscompile/linux_to_windows.sh index 0871489..fa399ab 100755 --- a/crosscompile/linux_to_windows.sh +++ b/crosscompile/linux_to_windows.sh @@ -19,7 +19,6 @@ set -x SOURCE_PATH=$(dirname $(dirname $0)) -shift # see if we need to update the conan configuration if test "${SOURCE_PATH}"/conanfile.txt -nt conan_paths.cmake || test "$0" -nt conan_paths.cmake; then From ce9f8824d70ca519e6c91db5b4cd59c48eebf841 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 17:36:51 +0100 Subject: [PATCH 47/54] Describe successful compilation in Wine --- crosscompile/wine.md | 104 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 16 deletions(-) diff --git a/crosscompile/wine.md b/crosscompile/wine.md index 9190a3c..3acd1ed 100644 --- a/crosscompile/wine.md +++ b/crosscompile/wine.md @@ -2,6 +2,29 @@ Note: This is work in progress and does not yet work to the end. It maybe never will. +## Why? I mean, why? Why not just use cross compilation? + +You want the deployed build to be as similar as possible to a build you can actually debug. So, +ideally, you would want to deploy builds done on a Windows machine with Windows development tools, +because that is where your hordes of Windows developers would be working. +But you may not have one readily available, so the next best thing is to use Windows build tools +on Wine. + +Also, using this way, all the build tools know they are compiling on Windows for Windows and will +name their output files accordingly. + +## Problem + +Conan can in principle build all our dependencies. On Wine, however, that fails, because Conan wants +to use msys2 to be able to use Unix-like build methods, and that does not work in Wine. There are no +usable prebuilt packages available. + +## Workaround + +Conan can use packages prebuilt with the cross compiler, provided the used compilers are similar enough. +A suitable environment with all the right tools on the Windows side is [w64devkit](https://github.com/skeeto/w64devkit). +It uses the same MinGW base as the cross compiler recommended in linux_to_windows.sh. + ## Setup Basically, follow the instructions for native Windows builds. @@ -13,16 +36,20 @@ However, winget does not work in wine, so you have to install everything by hand * Comfortable: > winetricks cmake * Manual: - https://cmake.org/download/ - - Pick the .msi installer + [Download](https://cmake.org/download/), pick the .msi installer Choose 'Add CMake to system PATH' (current user or all users should not matter) -* Python: https://www.python.org/downloads/windows/ +* w64devkit: + [Download](https://github.com/skeeto/w64devkit/releases), Pick the most basic w64devkit-*.zip + + Unzip to your Windows C drive (~/.wine/drive_c) directly, it will go to the folder + w64devkit. Nothing more is required. - Pick the 64 bit zip (embeddable) archive +* Python: + + [Download](https://www.python.org/downloads/windows/), pick the 64 bit zip (embeddable) archive Unzip to your Windows C drive (~/.wine/drive_c), directory Python @@ -32,8 +59,8 @@ However, winget does not work in wine, so you have to install everything by hand > wine regedit navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, - edit the value PATH; append ';C:\Python;C:\Python\Scripts;C:\Program Files\CodeBlocks\MinGW\bin'. - (the MinGW bit is for code::blocks later) + edit the value PATH; append ';C:\Python;C:\Python\Scripts;C:\w64devkit\bin'. + (the w64devkit bit also makes w64devkit your default dev environment) * Pip: Via the get-pip.py method: https://pip.pypa.io/en/stable/installation/#get-pip-py > wget https://bootstrap.pypa.io/get-pip.py @@ -52,17 +79,62 @@ However, winget does not work in wine, so you have to install everything by hand in ~/.wine/drive_c/Python. -And then you are stuck. +## Now comes the magic bit + +In Linux, at least once, do a cross compilation build with linux_to_windows.sh. It does not +have to be a complete build, getting the Conan-managed dependencies compiled is enough. +These dependencies are residing in ~/.conan/data. Important: Make sure that the cross compilation +MinGW you installed is compatible with the MinGW version of w64devkit. If the cross compilation +one has the same or a lower major version, that usually is good enough. + +The commands for that are, from the cerritos main directory: +> mkdir build_cross + +> cd build_cross + +> ../crosscompile/linux_to_windows.sh --cmake-should-fail + +Keep the directory around for now, we will need it. + +Then, also at least once, can be from the same directory, try to install +the dependencies via Conan. This will fail: + +> cd .. + +> mkdir build_win64 + +> cd build_win64 + +> wine conan install .. + +But now you have Conan set up in your wine environment. It expects its dependencies +in C:\Users\\your unix username\\.conan\\data. So, you simply link that directory +and the one from the cross compilation together: + +> rm -rf ~/.wine/drive_c/users/your unix username/.conan/data + +> ln -sf ~/.conan/data ~/.wine/drive_c/users/your unix username/.conan/ + +That is not quite enough, though; Conan only uses compiled packages of the +correct configuration. We have to convince it that the cross compilation +configuration is identical to the Wine configuration. Conan uses profile files +for that. The one for cross compilation is still in `../build_cross/win64.profile`. +The one for the Wine compilation is in +`~/.wine/drive_c/users/your unix username/.conan/profiles/default`. Open them both, +copy the values in the [settings] section from win64.profile to default. +The relevant ones would be os, arch, compiler, compiler.version, compiler.libcxx and +build_type. -## The following steps were tried, too +Here is also your chance to check whether the MinGW versions were compatible. In default, +Conan has detected the version of the one installed in Wine. So if you are making that +bigger in the major version, expect failures. -* Visual Studio Build Tools: - > winetricks vstools2019 -q +Then it is time for another go. This time, Conan should find and accept the precompiled +libraries. - Result: Could not install. +> wine conan install .. -* Instead of the big Visual Studio, you can try Code::Blocks with mingw. Download from https://www.codeblocks.org/downloads/binaries/#imagesoswindows48pnglogo-microsoft-windows - Pick the *mingw-setup.exe variant - > wine ./codeblocks-20.03mingw-setup.exe +CMake needs a special parameter to create usable makefiles: +> wine cmake .. -G "MinGW Makefiles" - Result: Installs fine, runs fine, autodetected by conan. However, 'conan install' then fails to build everything. +> wine cmake --build . From 4a2bf860830ea76e1d92864a2c1ad9aac5fe3740 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sat, 25 Feb 2023 17:48:18 +0100 Subject: [PATCH 48/54] Remove note that claims this does not work :) --- crosscompile/wine.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/crosscompile/wine.md b/crosscompile/wine.md index 3acd1ed..b47ed65 100644 --- a/crosscompile/wine.md +++ b/crosscompile/wine.md @@ -1,7 +1,5 @@ # How to compile for Windows under Wine -Note: This is work in progress and does not yet work to the end. It maybe never will. - ## Why? I mean, why? Why not just use cross compilation? You want the deployed build to be as similar as possible to a build you can actually debug. So, From aeb35430bc6d09b6f24e06641282f9ec528b028b Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Sun, 26 Feb 2023 01:06:06 +0100 Subject: [PATCH 49/54] Try and make conanfile compatible with w64devkit without losing functionality. Does not work. libjpeg always gets build via msys2 (or build fails), which later causes linker errors. --- conanfile.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/conanfile.py b/conanfile.py index 4f85c74..35d1340 100755 --- a/conanfile.py +++ b/conanfile.py @@ -3,7 +3,7 @@ # install dependencies with # conan install --build=missing -from conans import ConanFile, CMake +from conan import ConanFile class CerritosConan(ConanFile): settings = "os", "compiler", "build_type", "arch" @@ -16,12 +16,11 @@ class CerritosConan(ConanFile): requires = \ "sdl/[^2.0 >=2.26.1]", \ - "sdl_ttf/[^2.0 >=2.0.15]", \ + "sdl_ttf/[^2.0 >=2.0.19]", \ "sdl_image/[^2.0 >=2.0.5]", \ - "libpng/[^1]", \ - "xz_utils/[^5]" + "libpng/[^1]" - # libpng and xy_utils are for conflict resolution; apparently it is enough to just state the conflicting transitive + # libpng and is conflict resolution; apparently it is enough to just state the conflicting transitive # dependencies with a broad version specification. @@ -31,6 +30,13 @@ class CerritosConan(ConanFile): def configure(self): if self.settings.os != "Macos": self.options["sdl"].iconv = False + + # this would pull in xz_utils, which does not compile in native w64devkit + self.options["sdl_image"].with_libtiff = False + # should we want libtiff in general, just minimally avoid xz_utils: + self.options["libtiff"].lzma = False + # add if required: + # if self.settings.os == "Windows": def imports(self): self.copy("*.dll", dst="bin", src="bin") From f0ef42d5280e22ff749d79fe19ffcba61b22d911 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Mon, 27 Feb 2023 19:05:58 +0100 Subject: [PATCH 50/54] Revert "Try and make conanfile compatible with w64devkit" This reverts commit aeb35430bc6d09b6f24e06641282f9ec528b028b. native w64devkit compilation does not seem feasible. --- conanfile.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/conanfile.py b/conanfile.py index 35d1340..4f85c74 100755 --- a/conanfile.py +++ b/conanfile.py @@ -3,7 +3,7 @@ # install dependencies with # conan install --build=missing -from conan import ConanFile +from conans import ConanFile, CMake class CerritosConan(ConanFile): settings = "os", "compiler", "build_type", "arch" @@ -16,11 +16,12 @@ class CerritosConan(ConanFile): requires = \ "sdl/[^2.0 >=2.26.1]", \ - "sdl_ttf/[^2.0 >=2.0.19]", \ + "sdl_ttf/[^2.0 >=2.0.15]", \ "sdl_image/[^2.0 >=2.0.5]", \ - "libpng/[^1]" + "libpng/[^1]", \ + "xz_utils/[^5]" - # libpng and is conflict resolution; apparently it is enough to just state the conflicting transitive + # libpng and xy_utils are for conflict resolution; apparently it is enough to just state the conflicting transitive # dependencies with a broad version specification. @@ -30,13 +31,6 @@ class CerritosConan(ConanFile): def configure(self): if self.settings.os != "Macos": self.options["sdl"].iconv = False - - # this would pull in xz_utils, which does not compile in native w64devkit - self.options["sdl_image"].with_libtiff = False - # should we want libtiff in general, just minimally avoid xz_utils: - self.options["libtiff"].lzma = False - # add if required: - # if self.settings.os == "Windows": def imports(self): self.copy("*.dll", dst="bin", src="bin") From 39f6d844fed913bbc9914a08750a46516282c0a8 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Mon, 27 Feb 2023 19:28:13 +0100 Subject: [PATCH 51/54] Add MSYS2 instructions --- BUILDING | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/BUILDING b/BUILDING index 14e9270..b381292 100644 --- a/BUILDING +++ b/BUILDING @@ -4,12 +4,22 @@ How to build cerritos Linux (package names may vary), in Terminal: > {your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev freealut-dev +For the optional Conan path, install pip (https://pip.pypa.io/en/stable/installation/) +> python -m ensurepip --upgrade +then install conan over pip (https://docs.conan.io/en/2.0/installation.html): +> pip install 'conan<2.0' --upgrade + macOS: 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: +For the optional Conan path, install pip (https://pip.pypa.io/en/stable/installation/) +> python -m ensurepip --upgrade +then install conan over pip (https://docs.conan.io/en/2.0/installation.html): +> pip install 'conan<2.0' --upgrade + +Windows via Visual Studio and Conan (will not have OpenAL support): 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): @@ -27,6 +37,15 @@ In Git Bash (installed with git), install pip (https://pip.pypa.io/en/stable/ins then install conan over pip (https://docs.conan.io/en/2.0/installation.html): > pip install 'conan<2.0' --upgrade +Windows via MSYS2, a more Unix-like environment (not yet fully functional): +Install MSYS2 (https://www.msys2.org/) +Start a shell in the MINGW32 environment (or, should you want 64 bit binaries, MINGW64) +Install pactoys for easier typing: +> pacman -S pactoys +Install dependencies: +> pacboy -S cmake:p gcc:p SDL2:p SDL2_ttf:p SDL2_image:p openal:p freealut:p doxygen:p graphviz:p +Optionally also make:p for makefile based compilation if you prefer that; the system defaults to ninja. + Cross Compilation: Look at the scripts and documentation in the crosscompile directory @@ -34,7 +53,7 @@ Look at the scripts and documentation in the crosscompile directory > mkdir build > cd build -3: Get Dependencies via Conan (Optional on Linux and macOS if nothing went wrong in step 1, required on Windows): +3. Get Dependencies via Conan (Optional on Linux, macOS and MSYS2 if nothing went wrong in step 1, required for Visual Studio): > conan install .. --build=missing 4. Run cmake From d6842651862cc9ce4b4c25db5ec398f556136554 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Mon, 27 Feb 2023 19:37:51 +0100 Subject: [PATCH 52/54] Visual Studio SDL also does not have the iconv option --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 4f85c74..3385a86 100755 --- a/conanfile.py +++ b/conanfile.py @@ -29,7 +29,7 @@ class CerritosConan(ConanFile): # Hope it is optional or can be manually installed if needed. def configure(self): - if self.settings.os != "Macos": + if self.settings.os != "Macos" and self.settings.compiler != "Visual Studio": self.options["sdl"].iconv = False def imports(self): From 4ca11640a532d5ec6adce0af809121248ebabc3f Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Mon, 27 Feb 2023 19:45:00 +0100 Subject: [PATCH 53/54] Remove SDLMain from linking Why did I think we need that? --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e0c9038..2d08bf8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,7 +89,6 @@ target_include_directories(cerritos SYSTEM PUBLIC target_link_libraries(cerritos PUBLIC SDL2::SDL2 - SDL2::SDL2main SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf $<$,$,9.1>>:stdc++fs> From 897a786eb2a3dbb28fc7e0206d10fea678e28906 Mon Sep 17 00:00:00 2001 From: Manuel Moos Date: Mon, 27 Feb 2023 20:01:31 +0100 Subject: [PATCH 54/54] Add better dependency install information on specific Linux distributions --- BUILDING | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/BUILDING b/BUILDING index b381292..016ff1d 100644 --- a/BUILDING +++ b/BUILDING @@ -3,8 +3,12 @@ How to build cerritos 1. Install dependencies Linux (package names may vary), in Terminal: > {your packager} libsdl2 doxygen graphviz libsdl2-image-dev libsdl2-ttf-dev freealut-dev +For example, on Arch: +> sudo pacman -S cmake make gcc sdl2 sdl2_ttf sdl2_image openal freealut doxygen graphviz +On Ubuntu: +> sudo apt install cmake make gcc libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libopenal-dev doxygen graphviz -For the optional Conan path, install pip (https://pip.pypa.io/en/stable/installation/) +For the optional Conan path, install python, then pip (https://pip.pypa.io/en/stable/installation/) > python -m ensurepip --upgrade then install conan over pip (https://docs.conan.io/en/2.0/installation.html): > pip install 'conan<2.0' --upgrade @@ -12,9 +16,9 @@ then install conan over pip (https://docs.conan.io/en/2.0/installation.html): macOS: 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 +> brew install cmake make sdl2 sdl2_image sdl2_ttf freealut doxygen graphviz -For the optional Conan path, install pip (https://pip.pypa.io/en/stable/installation/) +For the optional Conan path, install python, pip (https://pip.pypa.io/en/stable/installation/) > python -m ensurepip --upgrade then install conan over pip (https://docs.conan.io/en/2.0/installation.html): > pip install 'conan<2.0' --upgrade