6

I'm trying to build libwebsockets inside of my project in CLion. During build libwebsockets creates a header file that is required by other files and puts it in PROJECT_BINARY_DIR. CLion builds everything inside a random build directory it creates for the project and the header file ends up in that directory. I've tried:

  • Setting the websockets_BINARY_DIR variable
  • Setting the CMAKE_RUNTIME_OUTPUT_DIRECTORY variable
  • Setting CMAKE_LIBRARY_OUTPUT_DIRECTORY variable
  • Changing every variable in the CMake cache to point away from CLion's random directory
  • Changing the build output path setting in CLion's preferences

None of these work, Which leads me to my questions:

  • Is there a way to tell CLion where to build (not just where to put some of its output buthow to override the random directory it chooses).
  • If there isn't a way to tell CLion where to build, is there another variable that I should be setting?
Huhwha
  • 575
  • 5
  • 15
  • In addition to answer below, check https://stackoverflow.com/questions/26819712/clion-changing-the-default-build-directory which is pretty much the same answer without the confusing link to use settings. – Bjorn Feb 15 '16 at 01:25

2 Answers2

9

I don't know how to set build dir.

Examples of how to set up bin directory with Clion below

set(dir ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${dir}/bin")

or (separate for .exe, .dll, .lib):

set(dir ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${dir}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${dir}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${dir}/bin")

Also I added link about how to set up build directory: https://stackoverflow.com/a/28200869/3001953

But it soesn't work in my case (Clion 1.1).

Community
  • 1
  • 1
Maks
  • 2,808
  • 4
  • 30
  • 31
0

You may also have a look at the Clion built-in path variables: https://www.jetbrains.com/help/clion/2019.2/absolute-path-variables.html

Jordan
  • 1,375
  • 14
  • 17