CMake issues
-
I have recently installed Qt Creator 7.0.2 with 'cmake' build option in ubuntu linux at the time of installation i.e. not separately. Single file the same is working alright but when going for multi file difficult with .h files. For a simple hello project against the following CMakeLists.txt file it is failing.
"cmake_minimum_required(VERSION 3.5)
project(FMI-Test LANGUAGES C)
set(SOURCES src/sample.cpp)
set(HEADERS include/sample.h)
add_executable(app main.c ${SOURCES} ${HEADERS})
target_include_directories(app PUBLIC include)"
However on running cmake from build option the project creating is not showing the include folder where sample.h file is kept, instead it is showing in the project folder under 'Header Files' folder unlike what is in File System. It is failing in building reporting 'undefined reference' of the function declared in sample.h file. However if I change #include sample.h in main.c file to #include sample.cpp it works. I have seen from command line the same result. Can anybody point out what the problem is? -
Hi and welcome to devnet,
Why are you stating that your application's language is C when using in fact C++ ? (That's what the .cpp extension hints to).