Closed benys closed 4 years ago
Hey, I haven't used CLion, so I can don't know if it's the best approach, but I would simply create a file at all/CMakeLists.txt
that includes the subprojects that you want to build simultaneously.
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(BuildAll LANGUAGES CXX)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../standalone ${CMAKE_BINARY_DIR}/standalone)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../test ${CMAKE_BINARY_DIR}/test)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../documentation ${CMAKE_BINARY_DIR}/documentation)
And use that to generate / configure your CLion project.
Thanks, it works now!
Thanks, @TheLartians for the suggestion.
I was trying to make the IDE see the test/
directory files.
When adding add_subdirectory(all)
to the main CMakeLists file, it gives the following error:
CMake Error at CMakeLists.txt:46 (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 "/home/mabuelanin/dib-dev/_play/ModernCppStarter". See
documentation for policy CMP0002 for more details.
CMake Error at all/CMakeLists.txt:10 (add_subdirectory):
The binary directory
/home/mabuelanin/dib-dev/_play/ModernCppStarter/cmake-build-debug/standalone
is already used to build a source directory. It cannot be used to build
source directory
/home/mabuelanin/dib-dev/_play/ModernCppStarter/standalone
Specify a unique binary directory name.
-- CPM: Greeter: adding package doctest@2.3.7 (2.3.7)
-- CPM: Greeter: adding package Format.cmake@1.6 (v1.6)
-- Found Python: /usr/bin/python3.8 (found version "3.8.5") found components: Interpreter
-- Format.cmake: clang-format and/or python not found, adding dummy targets
-- Format.cmake: cmake-format and/or git not found, adding dummy targets
-- CPM: Greeter: adding package MCSS@0 (42d4a9a48f31f5df6e246c948403b54b50574a2a)
CMake Error at all/CMakeLists.txt:11 (add_subdirectory):
The binary directory
/home/mabuelanin/dib-dev/_play/ModernCppStarter/cmake-build-debug/test
is already used to build a source directory. It cannot be used to build
source directory
/home/mabuelanin/dib-dev/_play/ModernCppStarter/test
Specify a unique binary directory name.
CMake Error at all/CMakeLists.txt:12 (add_subdirectory):
The binary directory
/home/mabuelanin/dib-dev/_play/ModernCppStarter/cmake-build-debug/documentation
is already used to build a source directory. It cannot be used to build
source directory
/home/mabuelanin/dib-dev/_play/ModernCppStarter/documentation
Specify a unique binary directory name.
@mr-eyes the all
subdirectory is already including the main CMakeLists, so you created a circular reference. 😉
Instead try opening the all
subdirectory directly from your IDE (or just the test
, if that interests you).
@TheLartians Yes, I see. It's a circular reference.
What I want is to develop in the test/
while opening the main project. But, as test/
is considered to be a different project for the IDE, its CMake can't be handled right.
Opening the all
directory in the IDE will prevent me to access any code in the project root dir or tests.
Everything is working fine in vscode, only Clion is the issue.
Yeah, combined development was actually the point of the all
directory, so it's interesting that CLion doesn't support it. I personally only use Xcode, VSCode and the command line, so I can't help much with that unfortunately.
I have tested Clion
, Visual Code
, and qtcreater.
To direct open an CMakeLists.txt
project like all
, qtcreator produce the best result!
Even better is to use cmake to generate a solution for i.e. Xcode, Visual Studio, ...
I would like to use this starter with Clion (from jetbrains).
I can't find out how to setup all. In FAQ you said that is possible to make folder for example 'All' with single build (standalone/tests). Can you make a little sample?