]> git.lyx.org Git - features.git/commitdiff
Cmake build: support tests
authorKornel Benko <kornel@lyx.org>
Tue, 16 Oct 2012 14:35:28 +0000 (16:35 +0200)
committerKornel Benko <kornel@lyx.org>
Tue, 16 Oct 2012 14:35:28 +0000 (16:35 +0200)
Next try to make it to work on APPLE (and maybe on WIN32)
a.) Create the needed data-dir at configure time
b.) Use different target names for executable and data created with them

src/support/tests/CMakeLists.txt

index 213b578a4ff68d5294e14f37259000cc67910115..eb6c2a1f481e031b756b832fa3f1716e304e63df 100644 (file)
@@ -28,20 +28,22 @@ include_directories(
 
 set(check_PROGRAMS check_convert check_filetools check_lstrings)
 
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/regfiles")
+
 set(_depends)
 foreach(_src ${check_PROGRAMS})
        sources(${_src} ${_src}.cpp dummy_functions.cpp boost.cpp)
-       #message(STATUS "${_src}_SOURCES = " ${${_src}_SOURCES})
        string(REPLACE "check_" "" _srcx ${_src})
+       set(src_data_file "${TOP_SRC_DIR}/src/support/tests/regfiles/${_srcx}")
+       set(created_data_file "${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}_data")
        add_custom_command(
-               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}
-               COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/regfiles"
-               COMMAND "${CMAKE_BINARY_DIR}/bin/${_src}" > ${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}
-               COMMAND ${CMAKE_COMMAND} -E compare_files "${TOP_SRC_DIR}/src/support/tests/regfiles/${_srcx}" "${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}"
-               DEPENDS "${CMAKE_BINARY_DIR}/bin/${_src}" "${TOP_SRC_DIR}/src/support/tests/regfiles/${_srcx}"
-               COMMENT "'${CMAKE_BINARY_DIR}/bin/${_src}' > '${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}'"
+               OUTPUT "${created_data_file}"
+               COMMAND ${_src} > "${created_data_file}"
+               COMMAND ${CMAKE_COMMAND} -E compare_files "${src_data_file}" "${created_data_file}"
+               DEPENDS ${_src} "${src_data_file}"
+               COMMENT "${_src} > '${created_data_file}'"
        )
-       list(APPEND _depends "${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}")
+       list(APPEND _depends "${created_data_file}")
 endforeach()
 
 add_custom_target(checkregfiles DEPENDS support ${_depends})