CMake install() isn't supported?

I cannot seem to get install working correctly as well as packaging a deployable release.

Bellow is my CMake file example for installation:

-------------------------------------
project(exe1)

set(${PROJECT_NAME}_headers "")
set(${PROJECT_NAME}_sources main.cpp)

add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources})

target_link_libraries(${PROJECT_NAME} dll1)

# IS THIS NOT SUPPORTED BY CLION?
# ---------------------------------
install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib/static
)

-------------------------------------

If it is supported how do I go about running the build process
to create these directories and store the appropriate files within them.
4 comments
Comment actions Permalink

Hi Justin.

We have the issue in the tracker: https://youtrack.jetbrains.com/issue/CPP-838
Feel free to comment or upvote.
Does the workaround with using an external tool help you?

0
Comment actions Permalink

Hi Anna I'm not sure how I would use the external tool in this case. Could you or someone please explain to me how
I would go about setting it up so the binaries are installed as so?

./bin/example.exe
./bin/exampledll.dll
./bin/lib/static/examplelilb.lib
./bin/lib/static/exampledll.lib

0
Comment actions Permalink

Justin, sorry for the late response. The workaround in this case is to use make install as an External tool. To make it please do the following

  • in CMakeLists.txt specify install locations for your targets using absolute paths, here is one example

     install(TARGETS <list-of-your-target's-names>
        RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin
 
        LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/lib
 
        ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/lib/static)
 
  • go to list of Run/Debug configurations > Edit Configuration > create new Application target
  • in Target field select 'All targets', choose desired Configuration and any executable
  • in section Before launch select '+' to add Run External tool
  • in appeared Create tool window select path to make utility in Program field, set Parameters to install, to set Working directory go to Tools > CMake > Show Generated CMake Files and select inside the directory with Debug/Release/etc Makefile generated by CMake and copy its path (I attached screenshot of my settings just in case)
  • save new Run Configuration and Run it.



I know that this workaround may seem confusing at the first time, feel free to vote for the issue mentioned above to get it fixed soon.



Attachment(s):
Screen Shot 2015-09-18 at 01.35.00.png
0
Comment actions Permalink

Thank you, it seems to be a good-enough-in-the-short-term workaround, albeit a quite convoluted and not scaleable. Surprising that no progress seem to have been made on this in a year.

One simple way to make life easier would be to allow CMAKE variables (assuming CLion has the needed visibility) in the Working Directory field.

Up-voted CPP-838.

0

Please sign in to leave a comment.