I need help from the CMake Gurus.

Attached is my attempt at rewriting kdepim/akonadi/agents/nie/CMakeLists.txt.

The problem is:  the nepomuk-rcgen program creates a file that contains a list
of source files to compile into the nie library.

So you'll notice that I read the contents of the file into a variable and 
attempt
to use that in kde4_add_library().  But CMake complains that the input files
don't exist. 

I'm lost.
Help.

# a CMake script. envoke with the -P option

# must define
# BIN_INSTALL_DIR
# targetdir
# ontofile1, ontofile2, ontofile3, ontofile4

FIND_PROGRAM(_rcgen nepomuk-rcgen PATHS ${BIN_INSTALL_DIR} NO_DEFAULT_PATH)

if(NOT _rcgen)

  message(FATAL_ERROR "Failed to find the Nepomuk source generator. Did you install Soprano?" )

else(NOT _rcgen)

  FILE(TO_NATIVE_PATH ${_rcgen} _rcgen)

  execute_process(
    COMMAND ${_rcgen} --listheaders --prefix ${targetdir}/ --ontologies ${ontofile1} ${ontofile2} ${ontofile3} ${ontofile4}
    OUTPUT_VARIABLE _out_headers
    RESULT_VARIABLE _rcgen_result
    ERROR_QUIET
    )
  file(WRITE ${targetdir}/out_headers "${_out_headers}")

  # If the first call succeeds it is very very likely that the rest will, too
  if(${_rcgen_result} EQUAL 0)

    execute_process(
      COMMAND ${_rcgen} --listsources --prefix ${targetdir}/ --ontologies ${ontofile1} ${ontofile2} ${ontofile3} ${ontofile4}
      OUTPUT_VARIABLE _out_sources
      ERROR_QUIET
      )
    file(WRITE ${targetdir}/out_sources "${_out_sources}")

    execute_process(
      COMMAND ${_rcgen} --listincludes --ontologies ${ontofile1} ${ontofile2} ${ontofile3} ${ontofile4}
      OUTPUT_VARIABLE _out_includes
      ERROR_QUIET
      )
    file(WRITE ${targetdir}/out_includes "${_out_includes}")

    execute_process(
      COMMAND ${_rcgen} --writeall --templates "DUMMY" --target ${targetdir}/ --ontologies ${ontofile1} ${ontofile2} ${ontofile3} ${ontofile4}
      ERROR_QUIET
      )

  else(${_rcgen_result} EQUAL 0)

    message(FATAL_ERROR "Failed to generate Nepomuk resource classes. Do you have a recent Soprano version?")

  endif(${_rcgen_result} EQUAL 0)

endif(NOT _rcgen)
add_custom_command(
  OUTPUT 
    ${CMAKE_CURRENT_BINARY_DIR}/out_headers
    ${CMAKE_CURRENT_BINARY_DIR}/out_sources
    ${CMAKE_CURRENT_BINARY_DIR}/out_includes
  COMMAND ${CMAKE_COMMAND}
  ARGS 
    -DBIN_INSTALL_DIR=${BIN_INSTALL_DIR}
    -Dontofile1=${CMAKE_CURRENT_SOURCE_DIR}/nie.rdfs
    -Dontofile2=${CMAKE_CURRENT_SOURCE_DIR}/nco.rdfs
    -Dontofile3=${CMAKE_CURRENT_SOURCE_DIR}/nmo.rdfs
    -Dontofile4=${CMAKE_CURRENT_SOURCE_DIR}/nfo.rdfs
    -Dtargetdir=${CMAKE_CURRENT_BINARY_DIR}
    -P ${CMAKE_CURRENT_SOURCE_DIR}/rcgen.cmake
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/nie.rdfs
  DEPENDS
    ${CMAKE_CURRENT_SOURCE_DIR}/nie.rdfs
    ${CMAKE_CURRENT_SOURCE_DIR}/nco.rdfs
    ${CMAKE_CURRENT_SOURCE_DIR}/nmo.rdfs 
    ${CMAKE_CURRENT_SOURCE_DIR}/nfo.rdfs 
  )

add_custom_target(
  nie-gen
  ALL
  DEPENDS
    ${CMAKE_CURRENT_BINARY_DIR}/out_headers
    ${CMAKE_CURRENT_BINARY_DIR}/out_sources
    ${CMAKE_CURRENT_BINARY_DIR}/out_includes
)

file(READ ${CMAKE_CURRENT_BINARY_DIR}/out_headers _out_headers)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/out_sources _out_sources)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/out_includes _out_includes)

kde4_add_library(nie STATIC ${_out_sources})

target_link_libraries(nie ${QT_QTCORE_LIBRARY} ${NEPOMUK_LIBRARIES})
_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to