0

I make a libtest_lib.a file with cmake.

cmake_minimum_required(VERSION 3.8)
project(test)
set(CMAKE_CXX_STANDARD 98)
set(SOURCE_FILES library.cpp library.h)
add_library(test_lib ${SOURCE_FILES})

then in my executable C++ project ,I include the #include "library.h" and the CMakeList.txt:

cmake_minimum_required(VERSION 3.8)
project(study)
set(CMAKE_CXX_STANDARD 98)
set(SOURCE_FILES main.cpp)
add_executable(study ${SOURCE_FILES})
target_link_libraries(study libtest_lib.a) //libtest_lib.a file under the project path

but it fails.

/Users/bin381/CLionProjects/study/main.cpp:1:10: fatal error: 'library.h' file not found
binbin
  • 167
  • 2
  • 11
  • Possible duplicate of https://stackoverflow.com/questions/13703647 – aschepler Jul 25 '17 at 01:54
  • I need to include my `library.h` in my project [static-library-but-i-still-need-headers](https://stackoverflow.com/questions/2612027/static-library-but-i-still-need-headers) – binbin Jul 25 '17 at 08:56

1 Answers1

1

Please add the include directories as mentioned in the documentation : https://cmake.org/cmake/help/v3.0/command/include_directories.html Otherwise cmake will not be able to find where to look in for include files.

PrashanthBC
  • 275
  • 1
  • 10