makefile中的shell命令

时间:2011-01-14 12:39:45

标签: linux makefile cmake

我在linux上,我需要使用cmake创建一个Makefile,以这种方式修改我的makefile:

@old:

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.6

# Default target executed when no arguments are given to make.
default_target: all

...stuff

@new:

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.6

# Default target executed when no arguments are given to make.
default_target: all

       ln -s lib/libfreenect.so.0.0 lib/libfreenect.so

...stuff

我只需要在makefile中添加这个命令,但我不知道该怎么做..

这是指向我的CMakeLists.txt的链接:http://pastebin.com/YB2kDTr5

1 个答案:

答案 0 :(得分:2)

您可以使用add_custom_command。这是一个例子:

cmake_minimum_required(VERSION 2.8)
add_library(mylib SHARED lib.cxx)
add_custom_command(TARGET mylib POST_BUILD COMMAND 
                   "${CMAKE_COMMAND}" -E create_symlink libmylib.so blah.so)