使用Clion时无法构建GLM

时间:2019-05-26 21:45:46

标签: c++ cmake clion glfw glm-math

我正在CMake项目中使用实验性GLM哈希功能。 除非项目是由Clion生成的,否则一切都会正常进行。

在构建Clion生成的项目时,尽管启用了C ++ 11,但是GLM会引发错误“ GLM_GTX_hash需要C ++ 11标准库支持”(请参阅​​CMake日志)。 从终端生成相同的,生成的clion项目失败,并出现相同的错误。

但是,当使用cmake“手动”生成和构建项目时(甚至Clion都不知道),一切正常。符合预期。

GLM没有直接包含在CMakeList中。 GLFW包含/导入它。

示例CMakeLists.txt

(...)
set(CMAKE_CXX_STANDARD 11)

add_executable(Test main.cpp)
(...)
add_subdirectory("glfw" ${CMAKE_CURRENT_BINARY_DIR}/glfw)
target_include_directories(Test PUBLIC ${GLFW_INCLUDE_DIRS})
target_link_libraries(Test ${GLFW_LIBRARIES} glfw)

示例main.cpp

#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/hash.hpp>

int main() {
    return 0;
}

Clion构建输出:

/usr/bin/cmake --build /home/lukas/Test/cmake-build-debug --target Test -- -j 2
[ 89%] Built target glfw
Scanning dependencies of target Test
[ 94%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
In file included from /home/lukas/Test/main.cpp:8:
/usr/include/glm/gtx/hash.hpp:46:3: error: "GLM_GTX_hash requires C++11 standard library support"
#       error "GLM_GTX_hash requires C++11 standard library support"
        ^
1 error generated.
make[3]: *** [CMakeFiles/Test.dir/build.make:63: CMakeFiles/Test.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/Test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/Test.dir/rule] Error 2
make: *** [Makefile:118: Test] Error 2

终端输出(预期)

$ cmake -H. -Bbuild -G "Unix Makefiles" && cmake --build build                                                                                                                 
Scanning dependencies of target glfw
[  5%] Building C object glfw/src/CMakeFiles/glfw.dir/context.c.o
[ 10%] Building C object glfw/src/CMakeFiles/glfw.dir/init.c.o
[ 15%] Building C object glfw/src/CMakeFiles/glfw.dir/input.c.o
[ 21%] Building C object glfw/src/CMakeFiles/glfw.dir/monitor.c.o
[ 26%] Building C object glfw/src/CMakeFiles/glfw.dir/vulkan.c.o
[ 31%] Building C object glfw/src/CMakeFiles/glfw.dir/window.c.o
[ 36%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_init.c.o
[ 42%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o
[ 47%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_window.c.o
[ 52%] Building C object glfw/src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[ 57%] Building C object glfw/src/CMakeFiles/glfw.dir/posix_time.c.o
[ 63%] Building C object glfw/src/CMakeFiles/glfw.dir/posix_thread.c.o
[ 68%] Building C object glfw/src/CMakeFiles/glfw.dir/glx_context.c.o
[ 73%] Building C object glfw/src/CMakeFiles/glfw.dir/egl_context.c.o
[ 78%] Building C object glfw/src/CMakeFiles/glfw.dir/osmesa_context.c.o
[ 84%] Building C object glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 89%] Linking C static library libglfw3.a
[ 89%] Built target glfw
Scanning dependencies of target Test
[ 94%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
[100%] Linking CXX executable Test
[100%] Built target Test

现在我实际上是好奇的,而不是我在某个地方搞砸了,或者仅仅是一个错误。如果是这样,我应该在哪里报告? [Clion / Jetbrains?,GLM?,GLFW?,CMake?]

预先感谢

更新

我正在使用最新的(对我来说)内部版本:
CMake版本:3.14.4
操作系统:Arch Linux 5.0.18-1 x86_64 GNU / Linux [尽管该问题也
GLFW版本/提交:d834f01c GLM版本/提交:fce2abd0 Clion:2019.1.3
Clion EAP:2019.2 EAP

0 个答案:

没有答案