]> Creatis software - clitk.git/blob - cmake/FindGengetopt.cmake
Add rotate and translate option to clitkAffineTransform
[clitk.git] / cmake / FindGengetopt.cmake
1
2 # Attempt to find gengetopt. If not found, compile it.
3 FIND_PROGRAM(GENGETOPT gengetopt)
4 IF (GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
5   GET_FILENAME_COMPONENT(CLITK_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
6   ADD_SUBDIRECTORY(${CLITK_CMAKE_DIR}/gengetopt ${CMAKE_CURRENT_BINARY_DIR}/gengetopt)
7 ELSE(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
8   ADD_EXECUTABLE(gengetopt IMPORTED)
9   SET_PROPERTY(TARGET gengetopt PROPERTY IMPORTED_LOCATION ${GENGETOPT})
10 ENDIF(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
11
12 MACRO (WRAP_GGO GGO_SRCS)
13   FOREACH(GGO_FILE ${ARGN})
14     GET_FILENAME_COMPONENT(GGO_BASEFILENAME ${GGO_FILE} NAME_WE)
15     GET_FILENAME_COMPONENT(GGO_FILE_ABS ${GGO_FILE} ABSOLUTE)
16     SET(GGO_H ${GGO_BASEFILENAME}_ggo.h)
17     SET(GGO_C ${GGO_BASEFILENAME}_ggo.c)
18     SET(GGO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${GGO_H} ${CMAKE_CURRENT_BINARY_DIR}/${GGO_C})
19     ADD_CUSTOM_COMMAND(OUTPUT ${GGO_OUTPUT}
20                        COMMAND gengetopt
21                        ARGS < ${GGO_FILE_ABS}
22                               --output-dir=${CMAKE_CURRENT_BINARY_DIR}
23                               --arg-struct-name=args_info_${GGO_BASEFILENAME}
24                               --func-name=cmdline_parser_${GGO_BASEFILENAME}
25                               --file-name=${GGO_BASEFILENAME}_ggo
26                               --unamed-opts
27                               --conf-parser
28                               --include-getopt
29                        DEPENDS ${GGO_FILE_ABS}
30                       )
31     SET(${GGO_SRCS} ${${GGO_SRCS}} ${GGO_OUTPUT})
32     INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
33   ENDFOREACH(GGO_FILE)
34   SET_SOURCE_FILES_PROPERTIES(${${GGO_SRCS}} PROPERTIES GENERATED TRUE)
35 ENDMACRO (WRAP_GGO)