简体   繁体   中英

Why am I getting Error Cannot find source file in cmake?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM