From cd411bba1e3fc6cad11f2778a8dea3cda5257257 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Tue, 23 Jul 2013 20:57:53 +0200 Subject: [PATCH] add little modif to make the dft apps --- cmake/FindBuildF2pyModule.cmake | 2 +- cmake/FindTriqsTest.cmake.in | 10 +++---- cmake/TRIQSConfig.cmake.in | 51 ++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/cmake/FindBuildF2pyModule.cmake b/cmake/FindBuildF2pyModule.cmake index 01045544..61b992e6 100644 --- a/cmake/FindBuildF2pyModule.cmake +++ b/cmake/FindBuildF2pyModule.cmake @@ -26,7 +26,7 @@ macro (BuildF2pyModule target_name modulename module_pyf_name filelist1) # ... and a special target to build vertex.so, that depends on the sources files add_custom_command(OUTPUT ${modulename}.so COMMAND echo See `pwd`/f2pyBuild.log for logs - COMMAND ${PYTHON_INTERPRETER} temp_script.py > f2pyBuild.log 2>&1 + COMMAND ${TRIQS_PYTHON_INTERPRETER} temp_script.py > f2pyBuild.log 2>&1 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${filelist} ${CMAKE_CURRENT_SOURCE_DIR}/${module_pyf_name} ) diff --git a/cmake/FindTriqsTest.cmake.in b/cmake/FindTriqsTest.cmake.in index c75d275f..2d9555f9 100644 --- a/cmake/FindTriqsTest.cmake.in +++ b/cmake/FindTriqsTest.cmake.in @@ -44,7 +44,7 @@ macro(triqs_add_test_C_hdf testname h5diff_options) endmacro(triqs_add_test_C_hdf) # WRITE THE run_pytriqs_for_test file -file (WRITE ${CMAKE_BINARY_DIR}/run_pytriqs_for_test.sh "#!/bin/bash\n export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH\n ${TRIQS_PATH}/bin/pytriqs $@") +file (WRITE ${CMAKE_BINARY_DIR}/run_pytriqs_for_test.sh "#!/bin/bash\n export PYTHONPATH=${CMAKE_BINARY_DIR}/python:$PYTHONPATH\n ${TRIQS_PATH}/bin/pytriqs $@") execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run_pytriqs_for_test.sh) #SET(RUN_TEST @CMAKE_INSTALL_PREFIX@/bin/pytriqs) @@ -63,7 +63,7 @@ SET(ExecutableNameForTest ${RUN_TEST}) # triqs_add_triqs_test_script(ExampleTest) # where ExampleTest.py is the script and ExampleTest.output is the expected output # -macro(triqs_add_triqs_test_txt testname ) +macro(triqs_add_test_txt testname ) enable_testing() add_test(${testname} ${CMAKE_COMMAND} @@ -73,7 +73,7 @@ macro(triqs_add_triqs_test_txt testname ) -Dreference=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output -P @CMAKE_INSTALL_PREFIX@/share/triqs/cmake/run_test.cmake ) -endmacro(triqs_add_triqs_test_txt) +endmacro(triqs_add_test_txt) # - runs python_with_DMFT script # - compares the file named testname_output.h5 @@ -84,7 +84,7 @@ endmacro(triqs_add_triqs_test_txt) # triqs_add_triqs_test_hdf(ExampleTestH5 "-r" ) # where ExampleTestH5.py produces to be compared with ExampleTestH5_output.h5 with option "-r" and for all objects # -macro(triqs_add_triqs_test_hdf testname h5diff_options) +macro(triqs_add_test_hdf testname h5diff_options) set(h5diff_objects ${ARGN}) # grab additionnal arguments ! enable_testing() add_test(${testname} @@ -99,7 +99,7 @@ macro(triqs_add_triqs_test_hdf testname h5diff_options) -DH5_DIFF_OBJECTS=${h5diff_objects} -P @CMAKE_INSTALL_PREFIX@/share/triqs/cmake/run_test.cmake ) -endmacro(triqs_add_triqs_test_hdf) +endmacro(triqs_add_test_hdf) diff --git a/cmake/TRIQSConfig.cmake.in b/cmake/TRIQSConfig.cmake.in index da03c517..4b54eff6 100644 --- a/cmake/TRIQSConfig.cmake.in +++ b/cmake/TRIQSConfig.cmake.in @@ -47,7 +47,8 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) message(STATUS "TRIQS : Adding C++11 compilation flags -std=c++11 ") -add_definitions( -std=c++0x) +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") +#add_definitions( -std=c++0x) # Check compiler if (NOT CMAKE_CXX_COMPILER STREQUAL "@CMAKE_CXX_COMPILER@" ) @@ -112,3 +113,51 @@ else() set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif() endmacro() + + +# +# This macro builds the f2py module +# - target_name +# - +# +macro (triqs_build_f2py_module target_name modulename module_pyf_name filelist1) + + set(filelist ${filelist1} ${ARGN}) + set(filename temp_script.py) + # Copy all the files + EXECUTE_PROCESS(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/${module_pyf_name} ${CMAKE_CURRENT_BINARY_DIR} ) + FOREACH( f ${filelist}) + EXECUTE_PROCESS(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${CMAKE_CURRENT_BINARY_DIR} ) + ENDFOREACH(f) + # write the script that will build the f2py extension + SET(filename ${CMAKE_CURRENT_BINARY_DIR}/${filename} ) + FILE(WRITE ${filename} "import sys\n") + FILE(APPEND ${filename} "from numpy.f2py import main\n") + FILE(APPEND ${filename} "sys.argv = [''] +'-c --f77exec=${CMAKE_Fortran_COMPILER} --f90exec=${CMAKE_Fortran_COMPILER} -m ${modulename} ${modulename}.pyf ${filelist} -llapack'.split()\n") + FILE(APPEND ${filename} "main()\n") + + # We had the normal target of the module + add_custom_target(${target_name} ALL DEPENDS ${modulename}.so) + + # TODO : to be corrected with the filelist is more than one file. + # ... and a special target to build vertex.so, that depends on the sources files + add_custom_command(OUTPUT ${modulename}.so + COMMAND echo See `pwd`/f2pyBuild.log for logs + COMMAND ${TRIQS_PYTHON_INTERPRETER} temp_script.py > f2pyBuild.log 2>&1 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${filelist} ${CMAKE_CURRENT_SOURCE_DIR}/${module_pyf_name} + ) + + #FILE(RELATIVE_PATH rel ${CMAKE_SOURCE_DIR}/Modules ${CMAKE_CURRENT_SOURCE_DIR}/) + #install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${modulename}.so + # DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${ExecutableName}/triqs/${rel}/..) + +endmacro (triqs_build_f2py_module) + +macro (triqs_make_target_to_copy_all_py_files_from_python_dir_to_build_dir) +FILE(GLOB_RECURSE all_py_files RELATIVE ${CMAKE_SOURCE_DIR}/python *.py ) +SET(py_copy_tar ${CMAKE_BINARY_DIR}/py_copy.tar) +add_custom_command (OUTPUT ${py_copy_tar} DEPENDS ${all_py_files} + COMMAND cd ${CMAKE_SOURCE_DIR}/python && tar cf ${py_copy_tar} ${all_py_files} && mkdir -p ${CMAKE_BINARY_DIR}/python && cd ${CMAKE_BINARY_DIR}/python && tar xf ${py_copy_tar} ) +add_custom_target(py_copy ALL DEPENDS ${py_copy_tar}) +endmacro() +