fixed building in directories other than the package root

This commit is contained in:
Nicholas O'Connor 2017-03-23 18:22:09 -07:00
parent 5278b5d98b
commit 8b2cb4ceba

View File

@ -29,20 +29,21 @@ http://tclap.sourceforge.net and put the headers in ./include
endif(NOT TCLAP_FOUND) endif(NOT TCLAP_FOUND)
include_directories(include) include_directories(include)
set(src "${CMAKE_CURRENT_SOURCE_DIR}/src") set(src "${CMAKE_SOURCE_DIR}/src")
set(coggedfiles) set(coggedfiles)
file(GLOB_RECURSE cogfiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file(GLOB_RECURSE cogfiles RELATIVE "${CMAKE_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cog") "${CMAKE_SOURCE_DIR}/*.cog")
foreach(cogfile ${cogfiles}) foreach(cogfile ${cogfiles})
string(REGEX REPLACE ".cog\$" "" outfile "${cogfile}") string(REGEX REPLACE ".cog\$" "" outfile "${cogfile}")
set(thisfile "${CMAKE_CURRENT_SOURCE_DIR}/${outfile}") set(thisfile "${CMAKE_SOURCE_DIR}/${outfile}")
add_custom_command(OUTPUT "${thisfile}" PRE_BUILD add_custom_command(OUTPUT "${thisfile}" PRE_BUILD
COMMAND ${PYTHON_EXECUTABLE} -m cogapp -d -o "${outfile}" "${cogfile}" COMMAND ${PYTHON_EXECUTABLE} -m cogapp -d -o "${outfile}" "${cogfile}"
DEPENDS ${cogfile} DEPENDS ${cogfile}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Greasing the cog for ${thisfile}") COMMENT "Greasing the cog for ${thisfile}")
set(coggedfiles ${coggedfiles} "${thisfile}") set(coggedfiles ${coggedfiles} "${thisfile}")