Kayrosik
Kayrosik

Reputation: 171

Error “No rule to make target …”

I'm trying to run travis test,but I get the following error.

I checked my files and directories, all files are exist.

I think my mistake in cmake file, but I can't find it. Maybe someone can help me?

make[1]: *** No rule to make target CMakeFiles/test.dir/all', needed byCMakeFiles/Examples.dir/all'. Stop.

cmake_minimum_required(VERSION 2.8.7)

project(test)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)

option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
option(BUILD_TESTS "Build tests for webdavclient" ON)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tests/ /sources)
add_library(test STATIC ${CMAKE_CURRENT_SOURCE_DIR}/sources/client.cpp tests/main.cpp)

find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})
    target_link_libraries(test ${Boost_LIBRARIES})
endif()

if(UNIX)
    set(DEPENDS_LIBRARIES ${OPENSSL_LIBRARIES} ${CURL_LIBRARY} ${Boost_LIBRARIES})
elseif(MSVC)
    set(DEPENDS_LIBRARIES ${OPENSSL_LIBRARIES} ${CURL_LIBRARY} ${Boost_LIBRARIES} ws2_32)
endif()

add_executable(Examples ${CMAKE_CURRENT_SOURCE_DIR}/examples/main.cpp)
target_link_libraries(Examples ${PROJECT_NAME} ${DEPENDS_LIBRARIES})

if(BUILD_TESTS)
    enable_testing()
    file(GLOB ${PROJECT_NAME}_TEST_SOURCES tests/*.cpp)
    add_executable(init ${${PROJECT_NAME}_TEST_SOURCES})
    target_link_libraries(init ${PROJECT_NAME} ${DEPENDS_LIBRARIES})
    add_test(NAME init COMMAND init "-s" "-r" "compact" "--use-colour" "yes")
endif()

Upvotes: 4

Views: 6633

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 65870

Command enable_testing() among other things creates target test. But you already have library target with the same name. This confuses CMake. For avoid this, rename library target.

Also, it is not recommended to have target name same as the project. So, rename project too.

Upvotes: 4

Related Questions