Hello,
I'm new here so I will start by the begining.
My real name is Fabrice, I'm 45 and I live in France.
I have decided a few days ago to really invest more time in "hobbyist gamdev" because I always wanted but never really done. Of course I've done some little games but never really completed or shared them.
More recently, I have tested unity and godot engine and completed some mini games with that tools but I wanted something different so I returned to C++ and I've looked for a library.
I have played a little with SFML 3 and wanted to try SDL3.
That lead me to my first question 🙂
I try since about 4 or 5 nights to link SDL3 and SDL3_image to a project using a CMakeLists.txt file.
I succedded for SDL3 and that worked but as soon as I try to add SDL3_image that fail.
I'm not sure to be in the right place for ask that question but I hope someone can help me to solve / understand that problem.
The error I've got every time is SDL3_image can't find SDL3 (if needed I can send more informations)
There is the content of the file I have that works, I have tried so many things after that ... but never suceeded to add SDL3_image and don't even have tried other libs I planned to use.
# CMakeList.txt : fichier projet CMake de niveau supérieur, effectuez une configuration globale
# et incluez les sous-projets ici.
#
cmake_minimum_required (VERSION 3.16)
#! ! ! ! ! ! !
#set this to ON instead of OFF to ship the game!
#basically this will change the RESOURCES_PATH to be the local path
#! ! ! ! ! ! !
#delete the out folder after changing if visual studio doesn recognize the change
set(PRODUCTION_BUILD OFF CACHE BOOL "Make this a production build" FORCE)
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>:Release>")
add_compile_options(/arch:AVX2) #make sure SIMD optimizations take place
else()
add_link_options(-static-libstdc++ -static-libgcc)
add_compile_options(-mavx2 -mfma) # make sure SIMD optimizations take place, but on linux and other platforms
endif()
# set the output directory for built objects.
# This makes sure that the dynamic library goes into the build directory automatically.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
# Activez Rechargement à chaud pour les compilateurs MSVC si cela est pris en charge.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
project ("Aijin")
set(CMAKE_CXX_STANDARD 17)
file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Aijin/src/*.cpp")
add_executable(Aijin_Engine "${MY_SOURCES}")
#option(Aijin_SDL3 "Use vendored libraries" OFF)
set_property(TARGET Aijin_Engine PROPERTY CXX_STANDARD 17)
if(PRODUCTION_BUILD)
# setup the ASSETS_PATH macro to be in the root folder of your exe
target_compile_definitions(Aijin_Engine PUBLIC RESOURCES_PATH="./resources/")
# remove the option to debug asserts.
target_compile_definitions(Aijin_Engine PUBLIC PRODUCTION_BUILD=1)
else()
# This is useful to get an ASSETS_PATH in your IDE during development
target_compile_definitions(Aijin_Engine PUBLIC RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/")
target_compile_definitions(Aijin_Engine PUBLIC PRODUCTION_BUILD=0)
endif()
#Pour les fichiers headers
target_include_directories(Aijin_Engine PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Aijin/headers/")
target_include_directories(Aijin_Engine PUBLIC SDL3)
#Liens vers SDL3
target_link_libraries(Aijin_Engine PRIVATE SDL3::SDL3)
#Linkage statique SDL3 :
# Désactiver la bibliothèque partagée (dynamique)
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
# Activer la bibliothèque statique
set(SDL_STATIC ON CACHE BOOL "" FORCE)
# Incluez les sous-projets.
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Aijin/libraries EXCLUDE_FROM_ALL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Aijin/libraries/SDL3 EXCLUDE_FROM_ALL)
#Affichage console ou pas en fonction du type de Build
if(MSVC) # If using the VS compiler...
target_compile_definitions(Aijin_Engine PUBLIC _CRT_SECURE_NO_WARNINGS)
if(PRODUCTION_BUILD)
#YOU CAN REMOVE THE CONSOLE WITH THIS LINE!
set_target_properties(Aijin_Engine PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") #no console
endif()
elseif(MINGW) # Windows / MinGW GCC/Clang
if(PRODUCTION_BUILD)
# Remove console on Windows under MinGW
target_link_options(Aijin_Engine PRIVATE
-mwindows
)
endif()
elseif(APPLE OR UNIX) # macOS / Linux
if(PRODUCTION_BUILD)
target_link_options(Aijin_Engine PRIVATE -s)
endif()
endif()I think that is the end of my first post, sorry it's a little long to read and if you need more info to help me just ask 🙂
Have a nice day.