173 lines
4.8 KiB
CMake
173 lines
4.8 KiB
CMake
|
|
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
|
####### Any changes to this file will be overwritten by the next CMake run ####
|
|
####### The input file was PkgBinConfig.cmake.in ########
|
|
|
|
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
|
|
|
|
macro(set_and_check _var _file)
|
|
set(${_var} "${_file}")
|
|
if(NOT EXISTS "${_file}")
|
|
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(check_required_components _NAME)
|
|
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
|
if(NOT ${_NAME}_${comp}_FOUND)
|
|
if(${_NAME}_FIND_REQUIRED_${comp})
|
|
set(${_NAME}_FOUND FALSE)
|
|
endif()
|
|
endif()
|
|
endforeach()
|
|
endmacro()
|
|
|
|
####################################################################################
|
|
|
|
# Make a list of all configurations
|
|
# FIXME: Replace this with ${CMAKE_CONFIGURATION_TYPES}
|
|
set(CONFIGS "RELEASE" "DEBUG")
|
|
|
|
# Construct the executable names
|
|
set(ppp_OUTPUT_NAME_RELEASE "ppp")
|
|
set(ppp_OUTPUT_NAME_DEBUG "ppp_d")
|
|
|
|
|
|
# See if we can go the easy way when our dependency is also a target to be built
|
|
if (TARGET ppp)
|
|
set(ppp_EXECUTABLE ppp)
|
|
set(ppp_FOUND TRUE)
|
|
endif()
|
|
|
|
# See if the imported target already exists
|
|
if (TARGET ppp_IMPORTED_${TARGET_POSTFIX})
|
|
set(ppp_EXECUTABLE ppp_IMPORTED_${TARGET_POSTFIX})
|
|
set(ppp_FOUND TRUE)
|
|
endif()
|
|
|
|
|
|
# If the project is a target then it might not be built but we assume
|
|
# nevertheless that the files will be present. If it is not a target then
|
|
# we look for the libraries explicitly
|
|
if (NOT ppp_FOUND)
|
|
set(FIND_PATHS "${PACKAGE_PREFIX_DIR}/framework/lib/unix"
|
|
"${PACKAGE_PREFIX_DIR}/framework/bin/unix"
|
|
"${PACKAGE_PREFIX_DIR}/build/bin/unix"
|
|
"${PACKAGE_PREFIX_DIR}/build/lib/unix")
|
|
|
|
# Try to find executables for all configurations
|
|
foreach(conf ${CONFIGS})
|
|
find_program(ppp_EXE_${conf} ${ppp_OUTPUT_NAME_${conf}} PATHS ${FIND_PATHS})
|
|
endforeach()
|
|
|
|
# Check if all program types could be found
|
|
set(ALL_EXES_FOUND TRUE)
|
|
foreach(conf ${CONFIGS})
|
|
if (NOT ppp_EXE_${conf})
|
|
set(ALL_EXES_FOUND FALSE)
|
|
break()
|
|
endif()
|
|
endforeach()
|
|
|
|
# If some programs could not be found then substitute their name with the
|
|
# first library name that could be found
|
|
if (NOT ALL_EXES_FOUND)
|
|
set(FIRST_FOUND_NAME FALSE)
|
|
|
|
foreach(conf ${CONFIGS})
|
|
if(ppp_EXE_${conf})
|
|
set(FIRST_FOUND_NAME ${ppp_EXE_${conf}})
|
|
break()
|
|
endif()
|
|
endforeach()
|
|
|
|
# If no program was found then we failed
|
|
if (NOT FIRST_FOUND_NAME)
|
|
# FIXME: add better error handling here
|
|
message(FATAL_ERROR "Could not find program ppp")
|
|
set(ppp_FOUND FALSE)
|
|
return()
|
|
endif()
|
|
|
|
# Set all library names that were not found
|
|
foreach(conf ${CONFIGS})
|
|
if(NOT ppp_EXE_${conf})
|
|
set(ppp_EXE_${conf} ${FIRST_FOUND_NAME})
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
# Generate an imported target which each location for different configurations set accordingly
|
|
add_executable(ppp_IMPORTED_${TARGET_POSTFIX} IMPORTED)
|
|
foreach(conf ${CONFIGS})
|
|
set_target_properties(ppp_IMPORTED_${TARGET_POSTFIX} PROPERTIES
|
|
IMPORTED_LOCATION_${conf} "${ppp_EXE_${conf}}")
|
|
endforeach()
|
|
|
|
set(ppp_EXECUTABLE ppp_IMPORTED_${TARGET_POSTFIX})
|
|
set(ppp_FOUND TRUE)
|
|
endif()
|
|
|
|
|
|
# Set output base
|
|
set(PH_BASE "${CMAKE_BINARY_DIR}/@BUILD_BASE@/@INSTALL_HEADER_PATH@")
|
|
|
|
|
|
macro(ppp_compile base outfiles)
|
|
|
|
get_filename_component(PPP_BASE "${base}" ABSOLUTE)
|
|
|
|
# Add a custom build rule for every file
|
|
foreach (infile ${ARGN})
|
|
ppp_command_add("${PPP_BASE}" "${infile}" outfile)
|
|
set(${outfiles} "${${outfiles}}" "${outfile}")
|
|
endforeach()
|
|
|
|
# Add the include directory
|
|
include_directories("${PH_BASE}")
|
|
endmacro()
|
|
|
|
|
|
macro(ppp_command_add base infile outfile)
|
|
|
|
# Set PPP working files
|
|
# These files are implicit dependencies and will be checked
|
|
# for the data. Specify the additional files that are used by the ppp
|
|
# set(PPP_WORK_FILES
|
|
# file1.ppp
|
|
# file2.ppp)
|
|
|
|
# Generate the output name
|
|
|
|
get_filename_component(PH_ABS "${infile}" ABSOLUTE)
|
|
file(RELATIVE_PATH PH_REL "${base}" "${PH_ABS}")
|
|
|
|
if (IS_ABSOLUTE "${PH_REL}")
|
|
message(FATAL_ERROR "The ppp input file ${infile} was explicitely based to ${${PROJECT_NAME}_PPP_BASE} which is not a file base!")
|
|
endif()
|
|
|
|
get_filename_component(PH_PATH "${PH_BASE}/${PH_REL}" PATH)
|
|
|
|
get_filename_component(PH_NAME "${infile}" NAME_WE)
|
|
|
|
# Create the output directory if it does not exist
|
|
if (NOT EXISTS "${PH_PATH}")
|
|
file(MAKE_DIRECTORY "${PH_PATH}")
|
|
endif()
|
|
|
|
get_filename_component(${outfile} "${PH_PATH}/${PH_NAME}.h" ABSOLUTE)
|
|
|
|
# FIXME: Can we really do this?
|
|
include_directories(
|
|
"${PH_BASE}"
|
|
"${PH_PATH}")
|
|
|
|
# Add the build rule
|
|
add_custom_command(OUTPUT ${${outfile}}
|
|
COMMAND ppp
|
|
ARGS "-CGV_DIR=${CGV_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${infile}" "${${outfile}}"
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${${infile}}"
|
|
IMPLICIT_DEPENDS ${PPP_WORK_FILES})
|
|
endmacro()
|
|
|
|
|