Is there a way to configure CLion to use a local makefile to compile code, rather than CMake? I can't seem to find the way to do it from the build options.
相关问题
- CMakeList file to generate LLVM bitcode file from
- Makefile to compile lists of source files
- Have make fail if unit tests fail
- C++ - Compiling multiple files
- Undefined symbols for architecture x86_64: (Mac OS
相关文章
- How to arrange a Makefile to compile a kernel modu
- Makefile and use of $$
- Makefile: all vs default targets
- Automake Variables to tidy up Makefile.am
- How do I check the exit status of a Makefile shell
- Defining preprocessor symbols for CLion analyzer
- Marking a makefile dependency as optional or other
- How to instruct Makefile to use different compiler
Currently, only CMake is supported by CLion. Others build systems will be added in the future, but currently, you can only use CMake.
An importer tool has been implemented to help you to use CMake.
Edit:
Source : http://blog.jetbrains.com/clion/2014/09/clion-answers-frequently-asked-questions/
I am not very familiar with CMake and could not use Mondkin's solution directly.
Here is what I came up with in my CMakeLists.txt using the latest version of CLion (1.2.4) and MinGW on Windows (I guess you will just need to replace all: g++ mytest.cpp -o bin/mytest by make if you are not using the same setup):
And the custom Makefile is like this (it is located at the root of my project and generates the executable in a bin directory):
I am able to build the executable and errors in the log window are clickable.
Hints in the IDE are quite limited through, which is a big limitation compared to pure CMake projects...
Newest version has better support literally for any generated Makefiles, through the compiledb
Three steps:
install compiledb
run a dry make
(do the autogen, configure if needed)
there will be a compile_commands.json file generated open the project and you will see CLion will load info from the json file. If you your CLion still try to find CMakeLists.txt and cannot read compile_commands.json, try to remove the entire folder, re-download the source files, and redo step 1,2,3
Orignal post: Working with Makefiles in CLion using Compilation DB
While this is one of the most voted feature requests, there is one plugin available, by Victor Kropp, that adds support to makefiles:
Makefile support plugin for IntelliJ IDEA
Install
You can install directly from the official repository:
Settings > Plugins > search for
makefile
> Search in repositories > Install > RestartUse
There are at least three different ways to run:
It opens a pane named Run target with the output.
To totally avoid using CMAKE, you can simply:
Build your project as you normally with Make through the terminal.
Change your CLion configurations, go to (in top bar) :
Run -> Edit Configurations -> yourProjectFolder
Change the
Executable
to the one generated with MakeChange the
Working directory
to the folder holding your executable (if needed)Remove the
Build
task in theBefore launch:Activate tool window
boxAnd you're all set! You can now use the debug button after your manual build.
Even though currently only CMake is supported, you can instruct CMake to call
make
with your customMakefile
. Edit yourCMakeLists.txt
adding one of these two commands:When you tell
CLion
to run your program, it will try to find an executable with the same name of the target in the directory pointed byPROJECT_BINARY_DIR
. So as long as yourmake
generates the file whereCLion
expects, there will be no problem.Here is a working example:
Tell
CLion
to pass its $(PROJECT_BINARY_DIR) tomake
This is the sample
CMakeLists.txt
:Tell make to generate the executable in
CLion's
directoryThis is the sample
Makefile
:That is all, you may also want to change your program's working directory so it executes as it is when you run make from inside your directory. For this edit:
Run -> Edit Configurations ... -> mytest -> Working directory