带有CLION的OSX上的GLFW cmake错误

时间:2017-07-25 01:02:10

标签: c++ macos cmake glfw clion

我使用CMake GLEWGLFW3创建了一个非常小的项目但由于某种原因GLFWCMake中运行CLion时返回错误(如下所示)。我在Windows上运行的项目版本完全相同,编译和运行完美。

我原来是来自glfw3的源代码,但是OSX中有一个错误,它在FirstResponder上出错,但是GitHub上的代码似乎修复了这个问题,所以我一直在使用这个包而。一旦我从GitHub中取出项目,它似乎就会出现代码问题(windows使用网站glfw3)。我在GitHub上的项目不包含依赖项,因此平台之间的共享(OSX和Windows)和版本差异不应该导致任何错误,因为它们都是完全独立的。

层级

  • 项目来源目录
    • DEPS
      • glfw3
      • glew2
    • ...

cmake的

cmake_minimum_required(VERSION 3.8)
project(StormEngine)

set(CMAKE_CXX_STANDARD 17)

set(SOURCE_FILES main.cpp Engine/Logger/Logger.cpp Engine/Logger/Logger.h Engine/Engine.cpp Engine/Engine.h Engine/Window/Window.cpp Engine/Window/Window.h Engine/Helper/glfw_helper.h Engine/Events/Devices/Mouse.cpp Engine/Events/Devices/Mouse.h Engine/Events/Listeners/MouseManager.cpp Engine/Events/Listeners/MouseManager.h)
add_executable(StormEngine ${SOURCE_FILES})

#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/Deps/cmake")

set(GLFW_BUILD_DOCS OFF CACHE BOOL  "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOl "" FORCE)

add_subdirectory(${PROJECT_SOURCE_DIR}/Deps/glfw3)
target_link_libraries(StormEngine glfw)
include_directories(${PROJECT_SOURCE_DIR}/Deps/glfw3/include)


set(GLEW_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/Deps/glew2/include)
if (APPLE)
    set(GLEW_LIBRARY ${PROJECT_SOURCE_DIR}/Deps/glew2/lib/libGLEW.2.0.0.dylib)
elseif(WIN32 OR WIN64)
    add_definitions(-DGLEW_STATIC)
    set(GLEW_LIBRARY ${PROJECT_SOURCE_DIR}/Deps/glew2/lib/Release/Win32/glew32s.lib)
endif()
find_package(GLEW REQUIRED)

include_directories(${GLEW_INCLUDE_DIR})
target_link_libraries(StormEngine ${GLEW_LIBRARY})

find_package(OpenGL REQUIRED)
target_link_libraries(StormEngine ${OPENGL_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})

cmake错误输出

"/Users/Programmer/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/172.3317.49/CLion.app/Contents/bin/cmake/bin/cmake" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/Programmer/CLionProjects/StormEngine
CMake Warning (dev) at Deps/glfw3/CMakeLists.txt:3 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    GLFW_VERSION
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find Vulkan (missing:  VULKAN_LIBRARY VULKAN_INCLUDE_DIR) 
-- Using Cocoa for window creation
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Programmer/CLionProjects/StormEngine/cmake-build-debug

[Finished]

退出程序后以glfw错误回调的输出(以我的日志程序的格式)。我确定这是由cmake问题引起的,而不是与我的代码有关,因为在没有cmake错误的Windows上不会发生这种情况。

ERROR [Engine.cpp][18]: GLFW3 code( 65537 ) -> The GLFW library is not initialized

0 个答案:

没有答案