tags:

views:

22

answers:

1

Hi!

I'm pretty new to CMake and I have the following problem:

I have a number of C++ modules (executables) which together form a program package. The modules are controlled and executed by a driver program written in Python. In the build/installation process the Python program needs to be preprocessed with options set by the configuration process (currently Autoconf/Automake/Libtool). This is currently done with a make target which looks roughly like this (much simplified):

foobar: foobar.in
    sed -r 's/@USE_EXTMOD@/$(USE_EXTMOD)/' $< $@
    chmod 755 $@

What is a good way (i.e. the correct way) of achieving this in CMake? I guess could use a combination of configure_file() and (a non-portable) execute_process(), but is there a better way?

Best regards, jonas.

A: 

I found a satisfactory solution myself:

option (USE_EXTMOD "Use Python extension module" OFF)
option (DRIVER_DEBUG_MODE "Debug the extmod driver" OFF)

set (INST_BINDIR ${CMAKE_INSTALL_PREFIX}/bin)
configure_file(${Driver_SOURCE_DIR}/foobar.in foobar)

install(PROGRAMS ${Driver_BINARY_DIR}/foobar
    DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
    CONFIGURATIONS Release
    )

install(PROGRAMS ${Driver_BINARY_DIR}/foobar
    DESTINATION ${CMAKE_BINARY_DIR}/bin
    CONFIGURATIONS Debug
    )
Jonas Juselius