Building in CLion

2019-08-12 03:28发布

Is it possible to build a single file in CLion and see the actual compiler command line being used?

I have a large existing project, which CLion managed to load however it fails to build, I suspect because of various CmakLists.txt setting. However as far as I can tell you can only build an entire project and it gets built using -j 8 so you get a lot of output which does not include the command line being used so it's hard to know what to fix. i know CLion does create a temporary build directory in .clion10 but I was hoping not to have to go a fish around in that.

Also as a newbie to CLion I can't seem to work out how to undock Clion Windows ( on a Windows 7 box ). The "Floating" option doesn't seem to let me drag a Window outside of the main Clion window.

标签: clion
1条回答
劫难
2楼-- · 2019-08-12 03:59

You have to use add_executable command multiple times.

Here an example :

cmake_minimum_required(VERSION 3.3)
project(test_build)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(BUILD_1 main)
set(SOURCE_FILES_1 main.cc)
add_executable(${BUILD_1} ${SOURCE_FILES_1})

set(BUILD_2 main_2)
set(SOURCE_FILES_2 main_2.cc)
add_executable(${BUILD_2} ${SOURCE_FILES_2})

Old anwser :
You can use add_subdirectory(path_to_directory) to use an other CMakeLists and have multiples building process. ie: you have your cmakelists at the root of your project and multiple other in some files of your project. You just use add_subdirectory and you get other build options.

For your other question, on ubuntu i have to split the view and after i can drag in another floating window.

Under you can see one of my projects and the main CMakeLists.txt on the right

Project with multiple CMake

And the build options on CLion with this structure.

CLion build options

The CMakeLists.txt under the files are like full project builders.

查看更多
登录 后发表回答