Reputation: 13
i'm doing a cmake for a project using sfml and imgui I'm using submodules to get SFML, imgui and imgui-sfml from github and I have some errors and I can't find the cause.
my project structure is like this :
.
├── CMakeLists.txt
├── build
├── include
├── libs
│ ├── SFML
│ ├── imgui
│ └── imgui-sfml
├── src
└── tests
and my cmake is like this:
cmake_minimum_required(VERSION 3.21)
project(app)
set(CMAKE_CXX_STANDARD 17)
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")
set(LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs")
set(SFML_DIR "${LIBS_DIR}/SFML")
set(IMGUI_DIR "${LIBS_DIR}/imgui")
set(IMGUI_SFML_DIR "${LIBS_DIR}/imgui-sfml")
file(GLOB_RECURSE COMMON_SOURCES "${SOURCE_DIR}/*.cpp" "${TEST_DIR}/*.cpp")
list(REMOVE_ITEM COMMON_SOURCES "${SOURCE_DIR}/main.cpp" "${TEST_DIR}/main.cpp")
file(GLOB_RECURSE SFML_HEADERS "${SFML_DIR}/include/\*.hpp")
add_subdirectory(${LIBS_DIR}/sfml)
set(IMGUI_SFML_FIND_SFML OFF)
set(IMGUI_SFML_IMGUI_DEMO ON)
add_subdirectory(${IMGUI_SFML_DIR})
macro(create_target target sources)
add_executable(${target} ${sources})
target_sources(${target} PRIVATE ${COMMON_SOURCES})
target_link_libraries(${target} PRIVATE sfml-system sfml-window sfml-graphics ImGui-SFML::ImGui-SFML)
target_include_directories(${target} PRIVATE ${LIBS_DIR} ${INCLUDE_DIR} ${SFML_DIR}/include ${IMGUI_DIR} ${IMGUI_SFML_DIR})
endmacro()
create_target(app ${SOURCE_DIR}/main.cpp)
create_target(test ${TEST_DIR}/main.cpp)
I have a lot of errors saying that the imgui-sfml can't find some sfml enums etc.. here is a sample of thoses:
10%] Built target sfml-system
[ 45%] Built target sfml-window
[ 68%] Built target sfml-graphics
[ 68%] Building CXX object libs/imgui-sfml/CMakeFiles/ImGui-SFML.dir/imgui-SFML.cpp.o
/Users/loicpottier/Documents/GitHub/projet_recherche/libs/imgui-sfml/imgui-SFML.cpp:172:31: error: no member named 'X' in namespace 'sf::Joystick'
xAxis = sf::Joystick::X;
~~~~~~~~~~~~~~^
/Users/loicpottier/Documents/GitHub/projet_recherche/libs/imgui-sfml/imgui-SFML.cpp:173:31: error: no member named 'Y' in namespace 'sf::Joystick'
yAxis = sf::Joystick::Y;
~~~~~~~~~~~~~~^
/Users/loicpottier/Documents/GitHub/projet_recherche/libs/imgui-sfml/imgui-SFML.cpp:185:30: error: no member named 'Z' in namespace 'sf::Joystick'
axis = sf::Joystick::Z;
~~~~~~~~~~~~~~^
/Users/loicpottier/Documents/GitHub/projet_recherche/libs/imgui-sfml/imgui-SFML.cpp:303:57: error: no member named 'Arrow' in 'sf::Cursor'
loadMouseCursor(ImGuiMouseCursor_Arrow, sf::Cursor::Arrow);
~~~~~~~~~~~~^
/Users/loicpottier/Documents/GitHub/projet_recherche/libs/imgui-sfml/imgui-SFML.cpp:304:61: error: no member named 'Text' in 'sf::Cursor'
loadMouseCursor(ImGuiMouseCursor_TextInput, sf::Cursor::Text);
~~~~~~~~~~~~^
/Users/loicpottier/Documents/GitHub/projet_recherche/libs/imgui-sfml/imgui-SFML.cpp:305:61: error: no member named 'SizeAll' in 'sf::Cursor'
loadMouseCursor(ImGuiMouseCursor_ResizeAll, sf::Cursor::SizeAll);
~~~~~~~~~~~~^
If anyone see a problem in my cmake setup, please explain me, i tried many things and i can't figure why it isn't working.
Thanks in advance !
Adding sfml sources as executable in add_executable()
doesn't solve this.
adding sources in target_sources
doesn't change anything either
Upvotes: 0
Views: 205
Reputation: 13
In case someone is facing the same issue or something similar, I just found the solution !
It was very simple in fact. When switching from fetch to submodules, I switched from official release to the last commit too..
This led to differences between SFML and imgui-SFML.
Just doing a git checkout inside of the submodules with the release version's SHA1 resolved the problem.
Upvotes: 0