Using local makefile for CLion instead of CMake

后端 未结 6 799
醉酒成梦
醉酒成梦 2020-12-04 04:49

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.

6条回答
  •  星月不相逢
    2020-12-04 05:15

    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):

    cmake_minimum_required(VERSION 3.3)
    project(mytest)
    
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    
    add_custom_target(mytest ALL COMMAND mingw32-make WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
    

    And the custom Makefile is like this (it is located at the root of my project and generates the executable in a bin directory):

    all:
        g++ mytest.cpp -o bin/mytest
    

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

提交回复
热议问题