在尝试使用Windows上的cmake在cygwin中编译项目时,我得到了完全无法谷歌的错误。
有问题的CMakeLists.txt文件是:
# Minimum cmake version (required)
cmake_minimum_required( VERSION 2.8.4 )
# Project name
project( sdlinterface )
# Find SDL2
include( FindPkgConfig )
pkg_search_module( SDL2 REQUIRED sdl2 )
set (PROJECT_INCLUDE_DIR
${SDL2_INCLUDE_DIRS} # SDL headers
${PROJECT_SOURCE_DIR}/include
)
set (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(PROJECT_SRCS
${PROJECT_SOURCE_DIR}/SDLMain.cpp
${PROJECT_SOURCE_DIR}/SDLWindow.cpp
${PROJECT_SOURCE_DIR}/SDLEventLoop.cpp
)
# Set the compiler flags (specifically the c++11 one)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_INCLUDE_DIR}")
add_library(${PROJECT_NAME} SHARED ${PROJECT_SRCS})
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
# Link project with SDL
target_link_libraries(${PROJECT_NAME}
SDL2
)
为什么在我打电话时会想到编译一个cygwin目标?
完整的错误消息是
$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxxx/Projects/sdlgame/Source/build
make[2]: *** No rule to make target 'cygwin', needed by 'cygsdlinterface.dll'. Stop.
CMakeFiles/Makefile2:170: recipe for target 'Libraries/LEngine/sdlinterface/build/CMakeFiles/sdlinterface.dir/all' failed
make[1]: *** [Libraries/LEngine/sdlinterface/build/CMakeFiles/sdlinterface.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2
答案 0 :(得分:2)
也许不是解决方案,但至少有一些想法
include( FindPkgConfig )
您可以使用find_package(PkgConfig)
${SDL2_LIBRARIES}
和${SDL2_LDFLAGS}
代替target_link_libraries(... SDL2)