Issue
I have an existing cmake file that generates a .so library. I want to modify it so that it will then make a copy of the .so named something else. This is roughly what I have:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
PROJECT(test1)
SET(TEST_SOURCES f1.c)
ADD_LIBRARY(test SHARED ${TEST_SOURCES})
ADD_CUSTOM_COMMAND(
OUTPUT custom1
COMMAND cp libtest.so custom1
DEPENDS libtest.so)
I realise there are better ways than hardcoding the library name, I'm just doing this while I try and figure out how to make it work at all. What's the thing I'm missing that will cause my copy/rename custom command to run? Note: this is not an install-time thing. Thanks
Solution
add_custom_target(CopyAndRename
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/test.so ${CMAKE_BINARY_DIR}/SomeThingElse.so
)
add_custom_target introduces a new target named CopyAndRename. You can run it with:
cmake CopyAndRename
Answered By - Vertexwahn Answer Checked By - David Goodson (WPSolving Volunteer)