Reputation: 41
My first time attempt at CMake and I need some help
CMake /w Ninja & clang++ generates build files but no executable
/CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(Example)
include(find_compiler)
add_subdirectory(src)
src/CMakeLists.txt
add_executable(Example main.cpp)
I'm not sure what to do. Thank you.
Upvotes: 4
Views: 1733
Reputation: 1640
The primary purpose fo CMake
is to create all the build-related files needed to create your executable (i.e. to configure build system), not to build it, so the behaviour you are experiencing is expected.
(I suppose you used Ninja generator, i.e. you executed cmake with -G Ninja
as one of the parameters)
In order to actually build your executable, you must execute ninja
, after successful configuration (i.e. successful run of cmake
):
$ cd build_folder
$ cmake -G Ninja source_folder
$ ninja
if everything goes well, you should have Example
executable in you build folder.
You can also initiate actual building using CMake using following set fo commands:
$ cd build_folder
$ cmake -G Ninja source_folder
$ cmake --build .
cheers,
Upvotes: 4