foips
foips

Reputation: 641

CMake with cygwin " make[2]: *** No rule to make target 'cygwin' "

I'm getting this completely un-google-able error while trying to compile a project in cygwin using cmake on Windows.

The CMakeLists.txt file in question is:

# 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
)

Any ideas why when I call make it's trying to compile a cygwin target?

The full error message is

$ 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

Upvotes: 1

Views: 2212

Answers (1)

Peter Petrik
Peter Petrik

Reputation: 10195

Maybe not a solution, but at least some ideas

  1. use "Unix Makefiles" generator (probably you do)
  2. you use PROJECT_SOURCE_DIR before it is initialized (PROJECT_INCLUDE_DIR)
  3. files that you add to ADD_LIBRARY could be relative to ${CMAKE_CURRENT_SOURCE_DIR} path, so you do not need to specify that explicitely
  4. instead of include( FindPkgConfig ) you can use find_package(PkgConfig)
  5. use ${SDL2_LIBRARIES} and ${SDL2_LDFLAGS} instead of target_link_libraries(... SDL2)

Upvotes: 3

Related Questions