PRE_LINK and PRE_BUILD don't seem to work in CMake on linux (generating MakeFiles). The documentation says that only PRE_BUILD is not supported. But PRE_LINK doesn't work at all.
I was not sure if they misunderstood them or if something was missing.
(Currently, as a workaround, I added a fake target and POST_BUILD to it, and then created a dependency. But it has its own problems. For my setup, there are problems when doing parallel make (-j).
Code example:
cmake_minimum_required(VERSION 2.8.5)
project(custom_command_test)
add_custom_target(my_actual_target
COMMAND echo " I am the actual taget "
COMMENT "Running actual target"
)
add_custom_command(
TARGET my_actual_target
PRE_LINK
COMMAND echo "I am prelinked to actual target"
COMMENT " Running PRELINK action "
)
add_custom_command(
TARGET my_actual_target
PRE_BUILD
COMMAND echo " I am prebuilt to actual target"
COMMENT " Running PRE_BUILD action"
)
add_custom_command(
TARGET my_actual_target
POST_BUILD
COMMAND echo " I postbuild to actual target"
COMMENT " Running POST BUILD action "
)
Output:
> cmake .
-- The C compiler identification is GNU 4.4.2
-- The CXX compiler identification is GNU 4.4.2
-- Check for working C compiler: XXXX/gcc/4.4.2/bin/gcc
-- Check for working C compiler: XXXX/gcc/4.4.2/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: XXXX/gcc/4.4.2/bin/g++
-- Check for working CXX compiler: XXXX/gcc/4.4.2/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: XXXX
> make my_actual_target
Scanning dependencies of target my_actual_target
[100%] Running actual target
I am the actual taget
Running PRE_BUILD action
I am prebuilt to actual target
Running POST BUILD action
I postbuild to actual target
[100%] Built target my_actual_target
> cmake --version
cmake version 2.8.10.2
Any solution?
source
share