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}/../utilities/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")
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}
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
29 DEPENDS ${GGO_FILE_ABS}
31 set(${GGO_SRCS} ${${GGO_SRCS}} ${GGO_OUTPUT})
32 include_directories(${CMAKE_CURRENT_BINARY_DIR})
34 set_source_files_properties(${${GGO_SRCS}} PROPERTIES GENERATED TRUE)
35 if(CMAKE_COMPILER_IS_GNUCXX)
36 find_program(DEFAULT_GCC gcc)
37 exec_program(${DEFAULT_GCC} ARGS "-dumpversion" OUTPUT_VARIABLE GCCVER)
38 if("${GCCVER}" VERSION_GREATER "4.5.2")
39 set_source_files_properties(${${GGO_SRCS}} PROPERTIES COMPILE_FLAGS "-Wno-unused-but-set-variable")
40 endif("${GCCVER}" VERSION_GREATER "4.5.2")
41 endif(CMAKE_COMPILER_IS_GNUCXX)