0

I have a simple CMakeLists.txt

add_executable(myexecutable test.cpp)

I don't intend to use CMake to actually indirectly be responsible for building the program. I intend to use it so I can use CLion and have a nice IDE experience for working on my c++ program.

If I hit build in CLion, or cmake --build on the commandline, I want it to invoke my real buildtool. How can I specify a buildtool to run instead of the normal build cmake/clion would do? I have only been able to find add_custom_command which can be run before/after the normal cmake/clion build.

Lucas Meijer
  • 4,424
  • 6
  • 36
  • 53
  • I'm not sure what you're asking - do you want CMake to generate a special type of build file? Maybe take a look at CMake's makefile generator options? – flangford Feb 12 '17 at 19:43
  • 1
    You can modify almost everything you want regarding CMake's output with [toolchain files](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html). So what exactly do you want to use as a compiler/linker/make tool? Can you please give what you would call on the command line to invoke this "real buildtool"? – Florian Feb 12 '17 at 20:01
  • I'd recommend you to use KDevelop instead. At least it has custom project manager and does not force you to hack around IDE itself to let you work with it. – arrowd Feb 13 '17 at 05:33
  • @Florian: the build I run on the commandline is "./jam MyProgram". the program's build system is written in jam,which is not something I can change. – Lucas Meijer Feb 16 '17 at 11:12
  • @LucasMeijer Completly custom and not derived from another toolchains calling syntax? That's also possible. Would something like [this](http://stackoverflow.com/questions/38293535/generic-rule-from-makefile-to-cmake) suffice? Otherwise I need the complete commandline to be sure (where the input files/include dirs/flags are going and how to link). – Florian Feb 16 '17 at 11:24

1 Answers1

1

You need some fake target to let CLion understand which files are there in the project. Then you can add add_custom_target with your own build commands. So if you avoid building fake target, but instead run custom targets via run configuration by name (after CMake reload CLion will automatically create run configurations for such targets), they will call build for you.

nastasiak2512
  • 1,857
  • 14
  • 14