ELNS
(Milad Sadeghi DM)
July 16, 2020, 2:08pm
1
Hi all,
I have created a new cpp repository a day ago to re-implement my fortran code snippets in c plus plus language and this is default generated cmake file by clion IDE:
cmake_minimum_required(VERSION 3.16)
project(CPPCS)
set(CMAKE_CXX_STANDARD 14)
include_directories(.)
include_directories(cmake-build-debug)
include_directories(src)
add_executable(CPPCS
cmake-build-debug/cmake_install.cmake
cmake-build-debug/CMakeCache.txt
cmake-build-debug/Makefile
cmake-build-debug/Project.cbp
src/numerical_methods/Exercise_01.cpp
CMakeLists.txt
LICENSE
README.md)
This worked very well before i decided to re-implement other exercise. Now when i run the second exercise.
How can i fix this? I want to configure smake file so that every new cpp file can run without any conflict with other cpp file.
It’s very obvious just from looking at this that it was auto-generated.
Please change the add_executable()
call to:
add_executable(CPPCS src/numerical_methods/Exercise_01.cpp)
removing everything except the .cpp
file from add_executable()
. In addition, you don’t need include_directories(cmake-build-debug)
.
1 Like
ELNS
(Milad Sadeghi DM)
July 16, 2020, 2:27pm
3
should only one cpp executable be in cmake file?
No, you can have more than one executable, but those other files aren’t needed to build the executable.
1 Like
ELNS
(Milad Sadeghi DM)
July 16, 2020, 2:33pm
5
could you please provide me correct cmake configuration for my project?
I don’t know exactly what your project requires, but based on what you have so far I think it looks approximately like this:
cmake_minimum_required(VERSION 3.16)
project(CPPCS)
set(CMAKE_CXX_STANDARD 14)
include_directories(.)
include_directories(src)
add_executable(CPPCS
src/numerical_methods/Exercise_01.cpp)
1 Like