Answer the question
In order to leave comments, you need to log in
How to connect lib to your project?
I rarely use CMake. Everything seems to be simple. But then suddenly I got an error that I can not cope with:
CMake Error at CMakeLists.txt:6 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory "C:/projects/cmake/foo/src" is not a subdirectory of
"C:/projects/cmake/app/ src". When specifying an out-of-tree source a
binary directory must be explicitly specified.
cmake_minimum_required(VERSION 2.8)
project(hello_world)
set(SOURCE_EXE main.cpp)
include_directories(../../foo/src)
add_executable(main ${SOURCE_EXE})
add_subdirectory(../../foo/src)
target_link_libraries(main foo)
#include "foo.h"
int main(int argc, char** argv)
{
hello_world();
return 0;
}
cmake_minimum_required(VERSION 2.8)
project(foo)
set(SOURCE_LIB foo.cpp)
add_library(foo STATIC ${SOURCE_LIB})
void hello_world();
#include <iostream>
void hello_world()
{
std::cout << "Hello, World!" << std::endl;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question