CMakeLists.txt 3.06 KB
Newer Older
Remi Perenon's avatar
Remi Perenon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
#################################
# Commad line arguments section
#################################

cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)

#################################
# Project section
#################################

# The project is declared. It is a Fortran project.
project(Python_API Fortran)
set(LIBRARY_NAME powder_generation)
14
add_library(${LIBRARY_NAME} SHARED Extensions/CFML_API_PowderSimulation.f90 Extensions/powder_generation.f90 Extensions/forpy_mod.f90)
15
add_library(form_cif SHARED Extensions/form_CIF.f90 Extensions/forpy_mod.f90)
Remi Perenon's avatar
Remi Perenon committed
16
17
18
19
20
21
22
23
24

# Forpy must be preprocessed
set_source_files_properties(forpy_mod.f90 PROPERTIES COMPILE_FLAG "-cpp")

#################################
# Dependencies section
#################################
# Add a dependency to crysfml_common to keep sure that the crysfml_common library will be built first.
add_dependencies(${LIBRARY_NAME} crysfml_common)
25
add_dependencies(form_cif crysfml_common)
Remi Perenon's avatar
Remi Perenon committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#find_package(Python3 REQUIRED)
#include_directories(${Python3_INCLUDE_DIRS})
if(NOT PYTHON_LIBRARY_PATH)
  #For a strange reason, find_package must be launched twice !
  find_package(Python3 COMPONENTS Interpreter Development)
  find_package(Python3 COMPONENTS Interpreter Development)
  set(PYTHON_LIBRARY_PATH ${Python3_LIBRARIES})
endif()

if (UNIX)
  add_library(Python3_LIB SHARED IMPORTED)
  set_property(TARGET Python3_LIB PROPERTY IMPORTED_LOCATION ${PYTHON_LIBRARY_PATH})
elseif(WIN32)
  add_library(Python3_LIB STATIC IMPORTED)
  set_property(TARGET Python3_LIB PROPERTY IMPORTED_LOCATION ${PYTHON_LIBRARY_PATH})
endif()

# Set include and linking
include_directories(${CRYSFML_COMMON_MODULE_DIRECTORY})
target_link_libraries(${LIBRARY_NAME} crysfml_common)
target_link_libraries(${LIBRARY_NAME} Python3_LIB)
48
49
target_link_libraries(form_cif crysfml_common)
target_link_libraries(form_cif Python3_LIB)
Remi Perenon's avatar
Remi Perenon committed
50
51
52
53
54
55
56
57
58
59
60

#################################
# Install section
#################################
set_target_properties(${LIBRARY_NAME} PROPERTIES PREFIX "" OUTPUT_NAME "powder_generation")
if(APPLE)
    set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".so")
elseif(WIN32)
    set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".pyd")
endif()

61
set_target_properties(form_cif PROPERTIES PREFIX "" OUTPUT_NAME "crysfml_symmetry")
Remi Perenon's avatar
Remi Perenon committed
62
if(APPLE)
63
    set_target_properties(form_cif PROPERTIES SUFFIX ".so")
Remi Perenon's avatar
Remi Perenon committed
64
elseif(WIN32)
65
    set_target_properties(form_cif PROPERTIES SUFFIX ".pyd")
Remi Perenon's avatar
Remi Perenon committed
66
67
endif()

Remi Perenon's avatar
Remi Perenon committed
68
69
70
71
72
73
# The rules for installing the library.
install(DIRECTORY "" DESTINATION ${PYTHON_API_PREFIX}/CFML_api FILES_MATCHING PATTERN "*.py" PATTERN "Extensions" EXCLUDE)
if(WIN32)
install(TARGETS ${LIBRARY_NAME} RUNTIME DESTINATION ${PYTHON_API_PREFIX}/CFML_api)
else()
install(TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${PYTHON_API_PREFIX}/CFML_api)
74
install(TARGETS form_cif LIBRARY DESTINATION ${PYTHON_API_PREFIX}/CFML_api)
Remi Perenon's avatar
Remi Perenon committed
75
76
77
78
endif()
# Installing example files
install(DIRECTORY "../Examples" DESTINATION ${PYTHON_API_PREFIX} FILES_MATCHING PATTERN "*.py")
install(DIRECTORY "../Examples/Data" DESTINATION ${PYTHON_API_PREFIX}/Examples FILES_MATCHING PATTERN "*.cfl" PATTERN "*.cif")