diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2018-08-04 23:06:25 +0100 |
---|---|---|
committer | Edoardo Pasca <edo.paskino@gmail.com> | 2018-08-04 23:06:25 +0100 |
commit | bd874abcebae787ea1f1fddc138fb67a8abf9c9b (patch) | |
tree | 4a9ba4bb2ae350c7fc30178930d34901e08cbc6d | |
parent | ae957063126a421ee0892eff18c44cf8b4e99042 (diff) | |
download | regularization-bd874abcebae787ea1f1fddc138fb67a8abf9c9b.tar.gz regularization-bd874abcebae787ea1f1fddc138fb67a8abf9c9b.tar.bz2 regularization-bd874abcebae787ea1f1fddc138fb67a8abf9c9b.tar.xz regularization-bd874abcebae787ea1f1fddc138fb67a8abf9c9b.zip |
working CMake project for Win and conda/no-conda
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | Core/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Wrappers/Python/CMakeLists.txt | 58 | ||||
-rw-r--r-- | Wrappers/Python/conda-recipe/bld.bat | 15 | ||||
-rw-r--r-- | Wrappers/Python/conda-recipe/meta.yaml | 4 | ||||
-rw-r--r-- | Wrappers/Python/setup-regularisers.py.in | 4 |
6 files changed, 80 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d931ee..df596e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set (RGL_VERSION_MAJOR 1) set (RGL_VERSION_MINOR 0) set (CIL_VERSION_MAJOR 0) -set (CIL_VERSION_MINOR 9) +set (CIL_VERSION_MINOR 10) set (CIL_VERSION_PATCH 1) set (CIL_VERSION '${CIL_VERSION_MAJOR}.${CIL_VERSION_MINOR}.${CIL_VERSION_PATCH}' CACHE INTERNAL "Core Imaging Library version" FORCE) @@ -31,4 +31,6 @@ set (CIL_VERSION '${CIL_VERSION_MAJOR}.${CIL_VERSION_MINOR}.${CIL_VERSION_PATCH} #include(${CMAKE_SOURCE_DIR}/CMake/FindAnacondaEnvironment.cmake) add_subdirectory(Core) -add_subdirectory(Wrappers) +if (BUILD_WRAPPERS) + add_subdirectory(Wrappers) +endif()
\ No newline at end of file diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index e596da9..2665277 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -1,17 +1,18 @@ # Copyright 2018 Edoardo Pasca -cmake_minimum_required (VERSION 3.0) +#cmake_minimum_required (VERSION 3.0) -project(RGL) +project(RGL_core) #https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py # The version number. -set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) +#set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) # conda orchestrated build message("CIL_VERSION ${CIL_VERSION}") #include (GenerateExportHeader) - +option (BUILD_WRAPPERS "Build Wrappers" ON) +option (CONDA_BUILD "Conda Build" OFF) find_package(OpenMP) if (OPENMP_FOUND) diff --git a/Wrappers/Python/CMakeLists.txt b/Wrappers/Python/CMakeLists.txt index fa1a30b..464c916 100644 --- a/Wrappers/Python/CMakeLists.txt +++ b/Wrappers/Python/CMakeLists.txt @@ -68,4 +68,60 @@ else() set(SETUP_GPU_WRAPPERS "#CUDA NOT FOUND") endif() -configure_file("setup-regularisers.py.in" "setup-regularisers.py") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in" "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py") + + +find_package(PythonInterp) +find_package(PythonLibs) +if (PYTHONINTERP_FOUND) + message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") + message(STATUS "Python version ${PYTHON_VERSION_STRING}") +endif() +if (PYTHONLIBS_FOUND) + message(STATUS "Found PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}") + message(STATUS "Found PYTHON_LIBRARIES=${PYTHON_LIBRARIES}") +endif() + +if (PYTHONINTERP_FOUND) + message("Python found " ${PYTHON_EXECUTABLE}) + set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in") + set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py") + #set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/module/__init__.py") + set (DEPS "${CMAKE_BINARY_DIR}/Core/") + set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp") + + configure_file(${SETUP_PY_IN} ${SETUP_PY}) + + message("Core binary dir " ${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE}) + + if (CONDA_BUILD) + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core + ${PYTHON_EXECUTABLE} ${SETUP_PY} install + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + + else() + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE} + ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + + endif() + + + add_custom_target(PythonWrapper ALL DEPENDS ${OUTPUT}) + + #install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") +endif()
\ No newline at end of file diff --git a/Wrappers/Python/conda-recipe/bld.bat b/Wrappers/Python/conda-recipe/bld.bat index e47f8d9..e58808b 100644 --- a/Wrappers/Python/conda-recipe/bld.bat +++ b/Wrappers/Python/conda-recipe/bld.bat @@ -6,12 +6,15 @@ exit 1 mkdir "%SRC_DIR%\ccpi" ROBOCOPY /E "%RECIPE_DIR%\..\.." "%SRC_DIR%\ccpi" ROBOCOPY /E "%RECIPE_DIR%\..\..\..\Core" "%SRC_DIR%\Core" -cd %SRC_DIR%\ccpi\Python +::cd %SRC_DIR%\ccpi\Python +cd %SRC_DIR% :: issue cmake to create setup.py -cmake . +cmake -G "NMake Makefiles" %RECIPE_DIR%\..\..\..\ -DBUILD_WRAPPERS=ON -DCONDA_BUILD=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" -%PYTHON% setup-regularisers.py build_ext -if errorlevel 1 exit 1 -%PYTHON% setup-regularisers.py install -if errorlevel 1 exit 1 +::%PYTHON% setup-regularisers.py build_ext +::if errorlevel 1 exit 1 +::%PYTHON% setup-regularisers.py install +::if errorlevel 1 exit 1 +nmake install +if errorlevel 1 exit 1
\ No newline at end of file diff --git a/Wrappers/Python/conda-recipe/meta.yaml b/Wrappers/Python/conda-recipe/meta.yaml index ca28bae..115fcf5 100644 --- a/Wrappers/Python/conda-recipe/meta.yaml +++ b/Wrappers/Python/conda-recipe/meta.yaml @@ -21,7 +21,7 @@ requirements: - numpy x.x - setuptools - cython - - cil_regulariser =={{ environ['CIL_VERSION'] }} + # - cil_regulariser =={{ environ['CIL_VERSION'] }} - vc 14 # [win and py36] - vc 14 # [win and py35] - vc 9 # [win and py27] @@ -30,7 +30,7 @@ requirements: run: - python - numpy x.x - - cil_regulariser =={{ environ['CIL_VERSION'] }} + # - cil_regulariser =={{ environ['CIL_VERSION'] }} - vc 14 # [win and py36] - vc 14 # [win and py35] - vc 9 # [win and py27] diff --git a/Wrappers/Python/setup-regularisers.py.in b/Wrappers/Python/setup-regularisers.py.in index 7108683..542dcb4 100644 --- a/Wrappers/Python/setup-regularisers.py.in +++ b/Wrappers/Python/setup-regularisers.py.in @@ -27,11 +27,13 @@ except: extra_include_dirs = [numpy.get_include(), library_include_path] #extra_library_dirs = [os.path.join(library_include_path, "..", "lib")] extra_compile_args = [] -extra_library_dirs = [] +extra_library_dirs = [library_lib_path] extra_compile_args = [] extra_link_args = [] extra_libraries = ['cilreg'] +print ("extra_library_dirs " , extra_library_dirs) + extra_include_dirs += [os.path.join(".." , ".." , "Core"), os.path.join(".." , ".." , "Core", "regularisers_CPU"), os.path.join(".." , ".." , "Core", "inpainters_CPU"), |