前一段时间,我决定在cmake的学习和钻研自己,遇到了一些恼人的问题。
以下一些教程(包括OpenGL和GLEW),我建立了一个窗口模拟机上运行良好的一个基本的应用程序,但在特定时刻,仿真将不只是做的伎俩了,我切换到Xcode和也CMake的。
所以,我建立了一个基本的文件夹结构:
build
CMakeLists.txt
inc
lib
src
lib文件夹中包含的文件夹:
glew
glfw
这是从原来的下载(包括的CMakeLists.txt文件和所有)直解压
要包括库我用这两条线在我的根的CMakeLists.txt但只有GLEW我得到了一个“‘GL’未找到”错误
ADD_SUBDIRECTORY(lib/glfw)
ADD_SUBDIRECTORY(lib/glew)
当与cmake的建立我得到这个输出,我是不是很开心:(
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Using Cocoa for window creation
Using NSGL for context creation
Building GLFW only for the native architecture
checking for module 'gl'
package 'gl' not found
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.2/Modules/FindPkgConfig.cmake:340 (message):
A required package was not found
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.2/Modules/FindPkgConfig.cmake:502 (_pkg_check_modules_internal)
lib/glew/CMakeLists.txt:26 (pkg_check_modules)
Configuring incomplete, errors occurred!
See also "/Users/Makkura/Dropbox/PROGRAMMING/CPLUSPLUS_SANDBOX/CMAKE/SPARKY/build/Xcode/CMakeFiles/CMakeOutput.log".
我认为有一些错误的GLEW文件夹中的CMakeLists.txt文件。 我可以看到Windows和Linux的具体行动,但我不能看到OSX系统指定的任何东西。
project(GLEW)
cmake_minimum_required(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
set(GLEW_VERSION "1.11.0")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(GLEW_LIB_NAME glew32)
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(GLEW_LIB_NAME GLEW)
set(DLL_PREFIX lib)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
#
# All platforms need OpenGL
#
include(FindPkgConfig)
pkg_check_modules( OpenGL REQUIRED gl )
#
# Linux needs X11
#
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(X11 REQUIRED)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_C_FLAGS "${CFLAGS} ${CMAKE_C_FLAGS} -DGLEW_BUILD -DGLEW_NO_GLU -O2 -Wall -W" )
include_directories( ${PROJECT_SOURCE_DIR}/include )
add_library(GLEW_static STATIC src/glew.c )
add_library(GLEW_shared SHARED src/glew.c )
set_target_properties(GLEW_static PROPERTIES OUTPUT_NAME ${GLEW_LIB_NAME} PREFIX lib)
set_target_properties(GLEW_shared PROPERTIES OUTPUT_NAME ${GLEW_LIB_NAME} PREFIX "${DLL_PREFIX}")
target_link_libraries(GLEW_shared ${OpenGL_LDFLAGS})
add_library(GLEW_MX_static STATIC src/glew.c )
add_library(GLEW_MX_shared SHARED src/glew.c )
set_target_properties(GLEW_MX_static PROPERTIES OUTPUT_NAME ${GLEW_LIB_NAME}mx COMPILE_FLAGS "-DGLEW_MX" PREFIX lib)
set_target_properties(GLEW_MX_shared PROPERTIES OUTPUT_NAME ${GLEW_LIB_NAME}mx COMPILE_FLAGS "-DGLEW_MX" PREFIX "${DLL_PREFIX}")
target_link_libraries(GLEW_MX_shared ${OpenGL_LDFLAGS})
add_executable(glewinfo src/glewinfo.c)
target_link_libraries(glewinfo GLEW_shared ${OpenGL_LDFLAGS})
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(glewinfo ${X11_LIBRARIES})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_executable(visualinfo src/visualinfo.c)
target_link_libraries(visualinfo GLEW_shared ${OpenGL_LDFLAGS})
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(visualinfo ${X11_LIBRARIES})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(
TARGETS
GLEW_static
GLEW_shared
GLEW_MX_static
GLEW_MX_shared
glewinfo
visualinfo
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(CODE "execute_process( COMMAND bash -x -c \"sed -e 's%@prefix@%${CMAKE_INSTALL_PREFIX}%g' -e 's%@exec_prefix@%\\\${prefix}%g' -e 's%@libdir@%\\\${prefix}/lib%g' -e 's%@includedir@%\\\${prefix}/include%g' -e 's/\@version\@/${GLEW_VERSION}/g' -e 's/\@cflags\@//g' -e 's/\@libname\@/${GLEW_LIB_NAME}/g' -e 's|@requireslib@|glu|g' < ${CMAKE_SOURCE_DIR}/glew.pc.in > ${CMAKE_BINARY_DIR}/glew.pc\" )" )
install(CODE "execute_process( COMMAND bash -x -c \"sed -e 's%@prefix@%${CMAKE_INSTALL_PREFIX}%g' -e 's%@exec_prefix@%\\\${prefix}%g' -e 's%@libdir@%\\\${prefix}/lib%g' -e 's%@includedir@%\\\${prefix}/include%g' -e 's/\@version\@/${GLEW_VERSION}/g' -e 's/\@cflags\@/-DGLEW_MX/g' -e 's/\@libname\@/${GLEW_LIB_NAME}mx/g' -e 's|@requireslib@|glu|g' < ${CMAKE_SOURCE_DIR}/glew.pc.in > ${CMAKE_BINARY_DIR}/glewmx.pc\" )" )
install(FILES ${CMAKE_BINARY_DIR}/glew.pc ${CMAKE_BINARY_DIR}/glewmx.pc DESTINATION lib/pkgconfig)
只要我没有得到这个问题解决了,我不能继续我的发展。 我一直在寻找类似的问题好几天,但我无法找到任何明确的解决办法。 有没有人遇到这样类似的问题?