0

How to make cmake build script for project that use ecpg code generation and qt moc compiler?

Also how to add code generation in cmake (which is easy in make)?

Yaroslav Kishchenko
  • 475
  • 1
  • 4
  • 15

1 Answers1

0

This is how we added code generation for ecpg in cmake.

set( PGSQL_CMD "/usr/pgsql-9.3/bin/ecpg" )
set( PGSQL_ARG "input_file.pgc" )
add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/output_file.c
                    COMMAND ${PGSQL_CMD} ${PGSQL_ARG}
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/input_file.pgc
                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
user1766169
  • 1,932
  • 3
  • 22
  • 44
  • How this solution should look for multiple pgc files. Does I need to write add_custom_command every time? Also I think ecpg program could be mentioned without absolute path, because after postgreSQL upgrade it would became broken. – Yaroslav Kishchenko Jan 18 '15 at 05:29
  • Yes, you would need to write one add_custom_command for each pgc-file. – user1766169 Jan 18 '15 at 15:51