This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
60 lines (47 loc) · 2.17 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
cmake_minimum_required(VERSION 3.9.5)
project(ndreg)
set(PACKAGE_VERSION "0.0.1")
# Build metamorphosis binary
find_package(ITK)
if(NOT ITK_FOUND)
message(FATAL_ERROR "ITK not found. Please set ITK_DIR.")
endif()
find_program(PYTHON "python")
if(NOT PYTHON)
message(FATAL_ERROR "Python not found. Please set PYTHON.")
endif()
# Configure setup.py in binary directory
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
configure_file(${SETUP_PY_IN} ${SETUP_PY})
# Copy python source files to binary directory
set(PY_FILENAME_LIST "ndreg.py;__init__.py;__version__.py")
foreach(FILENAME ${PY_FILENAME_LIST})
set(SRC_PY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ndreg/${FILENAME})
set(BIN_PY_PATH ${CMAKE_CURRENT_BINARY_DIR}/ndreg/${FILENAME})
set(BIN_PY_PATH_LIST ${BIN_PY_PATH_LIST} ${BIN_PY_PATH})
add_custom_command(OUTPUT ${BIN_PY_PATH}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_PY_PATH} ${BIN_PY_PATH}
DEPENDS ${SRC_PY_PATH})
endforeach()
# Copy README.md to binary directory
set(SRC_README_PATH ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(BIN_README_PATH ${CMAKE_CURRENT_BINARY_DIR}/README.md)
add_custom_command(OUTPUT ${BIN_README_PATH}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_README_PATH} ${BIN_README_PATH}
DEPENDS ${SRC_README_PATH})
# Build ndreg egg
include(${ITK_USE_FILE})
add_subdirectory(ndreg)
# stuff for ndreg access
#add_executable(metamorphosis metamorphosis.cxx itkMetamorphosisImageRegistrationMethodv4.h itkMetamorphosisImageRegistrationMethodv4.hxx)
#target_link_libraries(metamorphosis ${ITK_LIBRARIES})
set(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
add_custom_command(OUTPUT ${TIMESTAMP}
COMMAND ${PYTHON} -m py_compile ${BIN_PY_PATH_LIST} # Check for syntax errors by compiling python files
COMMAND ${PYTHON} ${SETUP_PY} build # Make the egg
COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP} # Generate timestamp file
DEPENDS ${BIN_PY_PATH_LIST} ${BIN_README_PATH} metamorphosis)
add_custom_target(ndreg ALL DEPENDS ${TIMESTAMP})
# Install ndreg egg
install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install --user)")