Reputation: 533
I am trying to create a shared library using the files present in SOURCE. So I added as suggested by this post.
cmake_minimum_required(VERSION 3.0.2)
project(myproj)
set (SOURCE
${SOURCE}
${CMAKE_CURRENT_SOURCE_DIR}/src/io/IO1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/io/IO2.cpp
)
add_library(myprojlib SHARED SOURCE)
I get error even though I have set the source :
CMake Error at CMakeLists.txt:34 (add_library): Cannot find source file:
SOURCE
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx
Upvotes: 3
Views: 7268
Reputation: 10857
add_library(myprojlib SHARED SOURCE)
should be add_library(myprojlib SHARED ${SOURCE})
CMake
expects that you mean SOURCE is the filename of your source cdoe not a CMake
variable. The ${} syntax makes it clear that SOURCE is a CMake variable.
Upvotes: 4