My CMake debug-build problem with sfml and gtest libs #2617
-
ProblemI have some kind of problem with importing xmake to cmake, namely with the sfml and gtest libraries in debug mode. At a time when everything is good on xmake, both in debug mode and in release mode, cmake allows me to build the project only in release. In debug it gives a linking error. I could be wrong, but it looks like libraries and sources are compiled in different modes, although I specified otherwise in xmake. I also checked the installed packages in xrepo via scan, they also say that the libraries are built in debug mode. Please tell me what am I doing wrong? Xmake Versionv2.6.9+dev.d554a5355 Operating System Version and ArchitectureWindows 11 Pro 22H2 x64 IDE & pluginsVisual Studio Code + XMake + CMake Tools xmake.luaadd_rules("mode.debug", "mode.release")
add_requires("gtest", { configs={debug = true} })
add_requires("sfml", { configs={debug = true} })
target("XMakeGtest")
set_kind("binary")
add_files("src/*.cpp")
add_packages("gtest", "sfml") Generated CMakeLists.txt# this is the build file for project
# it is autogenerated by the xmake build system.
# do not edit by hand.
# project
cmake_minimum_required(VERSION 3.15.0)
cmake_policy(SET CMP0091 NEW)
project(XMakeGtest LANGUAGES CXX C)
# target
add_executable(XMakeGtest "")
set_target_properties(XMakeGtest PROPERTIES OUTPUT_NAME "XMakeGtest")
set_target_properties(XMakeGtest PROPERTIES RUNTIME_OUTPUT_DIRECTORY "d:/DevProjects/XMakeGtest/build/windows/x64/debug")
target_include_directories(XMakeGtest PRIVATE
C:/Users/roota/AppData/Local/.xmake/packages/g/gtest/1.12.1/76c21de89f6a443593477fb97ac7d7e3/include
C:/Users/roota/AppData/Local/.xmake/packages/s/sfml/2.5.1/7acfb26adf3e40cfbd63044e7eb61527/include
)
target_compile_definitions(XMakeGtest PRIVATE
SFML_STATIC
)
if(MSVC)
target_compile_options(XMakeGtest PRIVATE $<$<CONFIG:Debug>:-Od>)
else()
target_compile_options(XMakeGtest PRIVATE -O0)
endif()
if(MSVC)
target_compile_options(XMakeGtest PRIVATE -Zi)
else()
target_compile_options(XMakeGtest PRIVATE -g)
endif()
if(MSVC)
set_property(TARGET XMakeGtest PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(XMakeGtest PRIVATE
gmock
gtest
gtest_main
sfml-graphics-s-d
sfml-window-s-d
sfml-audio-s-d
sfml-network-s-d
sfml-main-d
sfml-system-s-d
opengl32
gdi32
user32
advapi32
ws2_32
winmm
)
target_link_directories(XMakeGtest PRIVATE
C:/Users/roota/AppData/Local/.xmake/packages/g/gtest/1.12.1/76c21de89f6a443593477fb97ac7d7e3/lib
C:/Users/roota/AppData/Local/.xmake/packages/s/sfml/2.5.1/7acfb26adf3e40cfbd63044e7eb61527/lib
)
target_sources(XMakeGtest PRIVATE
src/main.cpp
)
main.cpp#include <cstdlib>
#include <gtest/gtest.h>
#include <SFML/Graphics.hpp>
using namespace std;
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
window.draw(shape);
window.display();
}
return EXIT_SUCCESS;
} xrepo scan
Error
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
try run |
Beta Was this translation helpful? Give feedback.
try run
xmake update dev
update to dev and addset_runtime("MT")