Git Product home page Git Product logo

Comments (8)

ClausKlein avatar ClausKlein commented on May 13, 2024

-DCMAKE_BUILD_TYPE=Debug should help.

But CLion does not work correctly with an CMake Project.

Try it with Qt-creator, which allow you to change the CMake options and show the Project structure much better!

from moderncppstarter.

navono avatar navono commented on May 13, 2024

@ClausKlein thank you for response.

I modify some config in conan_integrate branch in my forked project, standalone and library worked, but test and documentation still failed if add it to root CMakeList.txt

add_subdirectory(app)
add_subdirectory(Greeter)
add_subdirectory(test)
#add_subdirectory(documentation)

with error:

CMake Error at app/CMakeLists.txt:35 (add_executable):
  add_executable cannot create target "App" because another target with the
  same name already exists.  The existing target is an executable created in
  source directory "/mnt/d/sourcecode/cpp/ModernCppStarter/app".  See
  documentation for policy CMP0002 for more details.

any suggestion?

from moderncppstarter.

navono avatar navono commented on May 13, 2024

with --debug-output mode:

CMake Error at app/CMakeLists.txt:35 (add_executable):
  add_executable cannot create target "App" because another target with the
  same name already exists.  The existing target is an executable created in
  source directory "/mnt/d/sourcecode/cpp/ModernCppStarter/app".  See
  documentation for policy CMP0002 for more details.


   Called from: [1]	/mnt/d/sourcecode/cpp/ModernCppStarter/app/CMakeLists.txt
   Returning to         /mnt/d/sourcecode/cpp/ModernCppStarter
   Called from: [1]	/mnt/d/sourcecode/cpp/ModernCppStarter/CMakeLists.txt
   Entering             /mnt/d/sourcecode/cpp/ModernCppStarter/Greeter
   Called from: [1]	/mnt/d/sourcecode/cpp/ModernCppStarter/CMakeLists.txt

...

CMake Error at Greeter/CMakeLists.txt:40 (add_library):
  add_library cannot create target "Greeter" because another target with the
  same name already exists.  The existing target is a static library created
  in source directory "/mnt/d/sourcecode/cpp/ModernCppStarter/Greeter".  See
  documentation for policy CMP0002 for more details.


   Called from: [1]	/mnt/d/sourcecode/cpp/ModernCppStarter/Greeter/CMakeLists.txt
   Returning to         /mnt/d/sourcecode/cpp/ModernCppStarter
   Called from: [1]	/mnt/d/sourcecode/cpp/ModernCppStarter/CMakeLists.txt
   Entering             /mnt/d/sourcecode/cpp/ModernCppStarter/test
   Called from: [1]	/mnt/d/sourcecode/cpp/ModernCppStarter/CMakeLists.txt

from moderncppstarter.

navono avatar navono commented on May 13, 2024

seems like

CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)

in test/CMakeList.txt and documentation/CMakeList.txt.

from moderncppstarter.

ClausKlein avatar ClausKlein commented on May 13, 2024

Dit you read the README.md?

The template should be used for a single library project only.
If you need to build more than one lib, you should use this template multiple times for each library.

Do not use add_subdirectories()!
It can't work with this template.

from moderncppstarter.

navono avatar navono commented on May 13, 2024

If single header libraries meas CPMAddPackage can only use once, that's sad, it's very unfriendly.

from moderncppstarter.

ClausKlein avatar ClausKlein commented on May 13, 2024

If single header libraries meas CPMAddPackage can only use once, that's sad, it's very unfriendly.

That is neither true nor unfriendly!
You can't create with CMake 2 targets with same name.

If you want to change the concept behind the ModernCppStarter Template, it is possible.
see for example

But read and understand the CMake Doku!

CPMAddPackage is used within this project. But is independent of it.

from moderncppstarter.

navono avatar navono commented on May 13, 2024

That is neither true nor unfriendly!

You're right, because I lack enough understanding of CMake, I will read the Doc and check your example code.

Thank you.

from moderncppstarter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.