Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Debug configuration with GreeterStandalone in CLion #104

Closed
navono opened this issue Mar 14, 2021 · 8 comments
Closed

How to Debug configuration with GreeterStandalone in CLion #104

navono opened this issue Mar 14, 2021 · 8 comments

Comments

@navono
Copy link

navono commented Mar 14, 2021

As I opened starter with CLion, I can't find binary in configuration.
CLion Settings:
CMake: CMake options: -Hall -Bbuild
Build directory: build.

Only Greeter and fmt shows in Debug configuration, How to configure to debug the binary module?

@ClausKlein
Copy link
Contributor

-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!

@navono
Copy link
Author

navono commented Mar 15, 2021

@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?

@navono
Copy link
Author

navono commented Mar 15, 2021

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

@navono
Copy link
Author

navono commented Mar 15, 2021

seems like

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

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

@ClausKlein
Copy link
Contributor

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.

@navono
Copy link
Author

navono commented Mar 16, 2021

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

@navono navono closed this as completed Mar 16, 2021
@ClausKlein
Copy link
Contributor

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.

@navono
Copy link
Author

navono commented Mar 16, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants