diff --git a/cmake/SmokeConfig.cmake.in b/cmake/SmokeConfig.cmake.in index 76089d7..7066b7b 100644 --- a/cmake/SmokeConfig.cmake.in +++ b/cmake/SmokeConfig.cmake.in @@ -1,100 +1,130 @@ # Find smoke libraries. # # Use: # # find_package(Smoke [REQUIRED] COMPONENTS QtCore QtGui ) # # Defines: # # SMOKE_INCLUDE_DIR Directory in which smoke.h is located # SMOKE_CMAKE_MODULE_DIR Directory with additional cmake files used by kdebindings # SMOKE_GEN_BIN The path of the smokegen executable # SMOKE_GEN_SHARED Directory in which commonly used smokegen files reside # SMOKE_API_BIN The path of the smokeapi executable # SMOKE_GENERATOR_SMOKE_LIB Path of generator_smoke library # SMOKE_GENERATOR_DUMP_LIB Path of generator_dump library # SMOKE__INCLUDE_DIR Directory in which to find smoke/_smoke.h # SMOKE__LIBRARY Library for the smoke lib # # Copyright (c) 2010, Arno Rehn # (c) 2010, Ian Monroe # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. ##################### # utility functions # ##################### function (_print type message) if (NOT Smoke_FIND_QUIETLY) message (${type} "${message}") endif (NOT Smoke_FIND_QUIETLY) endfunction (_print type message) ############################## # find individual smoke libs # ############################## macro (find_smoke_component name) string(TOUPPER ${name} uppercase) string(TOLOWER ${name} lowercase) if (NOT SMOKE_${uppercase}_FOUND) set (SMOKE_${uppercase}_FOUND FALSE CACHE INTERNAL "") find_path(SMOKE_${uppercase}_INCLUDE_DIR ${lowercase}_smoke.h HINTS ${SMOKE_INCLUDE_DIR} PATH_SUFFIXES smoke) find_library(SMOKE_${uppercase}_LIBRARY smoke${lowercase} HINTS "@SMOKE_LIBRARY_PREFIX@") if (NOT SMOKE_${uppercase}_INCLUDE_DIR OR NOT SMOKE_${uppercase}_LIBRARY) if (Smoke_FIND_REQUIRED) _print(FATAL_ERROR "Could not find Smoke${name}") else (Smoke_FIND_REQUIRED) _print(STATUS "Could not find Smoke${name}") endif (Smoke_FIND_REQUIRED) else (NOT SMOKE_${uppercase}_INCLUDE_DIR OR NOT SMOKE_${uppercase}_LIBRARY) set (SMOKE_${uppercase}_FOUND TRUE CACHE INTERNAL "") _print(STATUS "Found Smoke${name}: ${SMOKE_${uppercase}_LIBRARY}") endif (NOT SMOKE_${uppercase}_INCLUDE_DIR OR NOT SMOKE_${uppercase}_LIBRARY) mark_as_advanced(SMOKE_${uppercase}_INCLUDE_DIR SMOKE_${uppercase}_LIBRARY SMOKE_${uppercase}_FOUND) endif (NOT SMOKE_${uppercase}_FOUND) endmacro (find_smoke_component) ################ # find smoke.h # ################ set(SMOKE_INCLUDE_DIR "@SMOKE_INCLUDE_DIR@") set(SMOKE_CMAKE_MODULE_DIR "@SMOKE_CMAKE_MODULE_DIR@") set(SMOKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") set(SMOKE_GENERATOR_SMOKE_LIB "@SMOKE_GENERATOR_SMOKE_LIB@") set(SMOKE_GENERATOR_DUMP_LIB "@SMOKE_GENERATOR_DUMP_LIB@") set(SMOKE_GEN_BIN "@SMOKE_GEN_BIN@") set(SMOKE_GEN_SHARED "@SMOKE_GEN_SHARED@") set(SMOKE_API_BIN "@SMOKE_API_BIN@") find_library(SMOKE_BASE_LIBRARY smokebase PATHS "@SMOKE_LIBRARY_PREFIX@" NO_DEFAULT_PATH) if (NOT SMOKE_BASE_LIBRARY) if (Smoke_FIND_REQUIRED) _print(FATAL_ERROR "Could not find SMOKE") else (Smoke_FIND_REQUIRED) _print(STATUS "Could not find SMOKE") endif (Smoke_FIND_REQUIRED) endif (NOT SMOKE_BASE_LIBRARY) mark_as_advanced(SMOKE_INCLUDE_DIR SMOKE_BASE_LIBRARY) if (Smoke_FIND_COMPONENTS) foreach (component ${Smoke_FIND_COMPONENTS}) find_smoke_component(${component}) endforeach(component) endif (Smoke_FIND_COMPONENTS) + +function(get_smokegen_output_files RESULT_NAME numXfiles) + set(outputFiles "${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp") + foreach(i RANGE 1 ${numXfiles}) + list(APPEND outputFiles "${CMAKE_CURRENT_BINARY_DIR}/x_${i}.cpp") + endforeach() + set(${RESULT_NAME} ${outputFiles} PARENT_SCOPE) +endfunction() + +function(run_smokegen numXfiles smokegenArgs) + # Generate the list of output files based on numXfiles + + get_smokegen_output_files(outputFiles ${numXfiles}) + + add_custom_command( + OUTPUT ${outputFiles} + COMMAND ${SMOKE_GEN_BIN} + ARGS ${smokegenArgs} + DEPENDS + ${SMOKE_GEN_BIN} + #${SMOKE_GENERATOR_SMOKE_LIB} + "${CMAKE_CURRENT_SOURCE_DIR}/smokeconfig.xml" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + + set_property( + SOURCE ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp + APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp + ) +endfunction(run_smokegen)