0

I am new to the CMake environment and I am trying to learn it for OpenSceneGraph. I am following the instructions from the book "OpenSceneGraph 3.0 Beginners Guide". I am getting an error when I try to create the "Hello World" project in Chapter 3.

When I drag the CMakeLists.txt to the cmake-gui, I always get an error;

CMake Error at CMakeLists.txt:12 (add_executable):
  Cannot find source file:

    main.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at CMakeLists.txt:12 (add_executable):
  No SOURCES given to target: MyProject

According to the error I am getting, I need to specify the locations of the Sources but I could not get in which stage I need to do that.

I am struggling with the basics, and I need to learn these two programs for my thesis. I know the beginnings are hard to adjust, but I did not understand where I did a mistake. If anyone has faced the same problem, could you please help me?

Thank you for your help in advance.

P.S. I could provide more information regarding your answers, or questions.

  • "I need to specify the locations of the Sources but I could not get in which stage I need to do that." - You need to specify correct location of sources in the file `CMakeLists.txt`. In other words, at the time when you configure your project in CMake GUI you should have all your sources files and `CMakeLists.txt`. – Tsyvarev Aug 21 '21 at 12:08
  • @Tsyvarev Thank you for your fast response. As I said, I am following the steps of the book to reduce the chance of mistakes that I could I get (but still I am getting some errors :) ). The CMakeLists.txt of the book is given and I did just a copy-paste, but still, I got this error. Could you please give more detail about the following "_at the time when you configure your project in CMake GUI you should have all your sources files and CMakeLists.txt_". – MrColourBlind Aug 21 '21 at 12:57
  • 1
    Before the step 3, which tells to run CMake GUI, there is the step 2, which tells about `main.cpp` and its content. It seems you forgot to perform that step. – Tsyvarev Aug 21 '21 at 13:06
  • Welcome to StackOverflow! Regarding "more information" that you "could provide", there is no sense in withholding! In general, we ask for _complete_ [minimal, reproducible, examples](https://stackoverflow.com/help/minimal-reproducible-example). You could get closer to that by showing your CMakeLists.txt and the filesystem tree around it, for instance. – Alex Reinking Aug 21 '21 at 13:19
  • @Tsyvarev, Thank you. I managed to solve my question. – MrColourBlind Aug 24 '21 at 17:28
  • 1
    @AlexReinking Thank you for your warm welcome, I will keep that in my mind when I ask more questions :) – MrColourBlind Aug 24 '21 at 17:30

0 Answers0