diff options
Diffstat (limited to 'modules/TDEMacros.cmake')
-rw-r--r-- | modules/TDEMacros.cmake | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index b438deb..9b46b84 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -498,13 +498,15 @@ macro( tde_automoc ) endforeach( ) if( NOT _found ) get_filename_component( _moc_file "${_moc_file}" NAME ) - tde_message_fatal( "AUTOMOC error: '${_moc_file}' cannot be generated.\n Reason: '${_src_file}.h' not found." ) + tde_message_fatal( "AUTOMOC error: '${_moc_file}' cannot be generated.\n Reason: '${_src_header}.h' not found." ) endif( ) endif( ) # moc-ing header + file( RELATIVE_PATH _moc_file_relative "${CMAKE_BINARY_DIR}" "${_moc_file}" ) add_custom_command( OUTPUT ${_moc_file} COMMAND ${TMOC_EXECUTABLE} ${_header_file} -o ${_moc_file} + COMMENT "Generating ${_moc_file_relative}" DEPENDS ${_header_file} ) # create dependency between source file and moc file @@ -514,6 +516,44 @@ macro( tde_automoc ) endif( _moc_includes ) + else( EXISTS "${_src_file}" ) + + # for generated file, the path must match the binary directory + string( LENGTH "${CMAKE_BINARY_DIR}" CMAKE_BINARY_DIR_LEN ) + string( LENGTH "${_src_file}" _basename_len ) + if( ${_basename_len} LESS ${CMAKE_BINARY_DIR_LEN} ) + set( _basedir_prefix "${CMAKE_SOURCE_DIR}" ) + else( ) + string( SUBSTRING "${_src_file}" 0 ${CMAKE_BINARY_DIR_LEN} _basedir_prefix ) + endif( ) + if( ${_basedir_prefix} STREQUAL "${CMAKE_BINARY_DIR}" ) + file( RELATIVE_PATH _sourcename "${CMAKE_BINARY_DIR}" "${_src_file}" ) + file( RELATIVE_PATH _basename "${CMAKE_CURRENT_BINARY_DIR}" "${_src_file}" ) + else( ) + file( RELATIVE_PATH _sourcename "${CMAKE_SOURCE_DIR}" "${_src_file}" ) + file( RELATIVE_PATH _basename "${CMAKE_CURRENT_SOURCE_DIR}" "${_src_file}" ) + endif( ) + + # automocing generated file + get_filename_component( _automoc_file "${_src_file}+automoc" NAME ) + set( _automoc_file "${CMAKE_CURRENT_BINARY_DIR}/${_automoc_file}" ) + + add_custom_command( OUTPUT ${_automoc_file} + COMMAND ${CMAKE_COMMAND} + -DTMOC_EXECUTABLE:FILEPATH=${TMOC_EXECUTABLE} + -DSRC_FILE:FILEPATH=${CMAKE_CURRENT_BINARY_DIR}/${_basename} + -DMETA_INCLUDES:STRING="${_meta_includes}" + -DMASTER_SOURCE_DIR:FILEPATH=${CMAKE_SOURCE_DIR} + -DMASTER_BINARY_DIR:FILEPATH=${CMAKE_BINARY_DIR} + -P ${TDE_CMAKE_MODULES}/tde_automoc.cmake + COMMENT "Automocing ${_sourcename}" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_basename}" + ) + + # create dependency between source file and moc file + set_property( SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${_basename}" + APPEND PROPERTY OBJECT_DEPENDS ${_automoc_file} ) + endif( EXISTS "${_src_file}" ) endforeach( _src_file ) |