CMakeLists.txt 4.22 KB
Newer Older
Remi Perenon's avatar
Remi Perenon committed
1
2
3
4
5
6
7
8
9
10
#################################
# 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)
11
set(LIBRARY_NAME crysfml_api)
12
13
add_library(${LIBRARY_NAME} SHARED
  Extensions/API_init.f90
Elisa Rebolini's avatar
Elisa Rebolini committed
14
  Extensions/API_Atom_TypeDef.f90
15
16
  Extensions/API_Crystallographic_Symmetry.f90
  Extensions/API_Crystal_Metrics.f90
Elisa Rebolini's avatar
Elisa Rebolini committed
17
  Extensions/API_Diffraction_Patterns.f90
18
  Extensions/API_IO_Formats.f90
19
  Extensions/API_Reflections_Utilities.f90
20
  Extensions/API_Structure_Factors.f90
21
  Extensions/CFML_API_Calc_Powder_Pattern.f90
22
  Extensions/forpy_mod.f90)
Remi Perenon's avatar
Remi Perenon committed
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

# 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)

#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)

Remi Perenon's avatar
Remi Perenon committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#################################
# Documentation
#################################
find_package(Doxygen)
if (DOXYGEN_FOUND)
	set( DOXYGEN_OUTPUT_DIRECTORY doxygen )
	set( DOXYGEN_COLLABORATION_GRAPH YES )
	set( DOXYGEN_EXTRACT_ALL YES )
	set( DOXYGEN_CLASS_DIAGRAMS YES )
	set( DOXYGEN_HIDE_UNDOC_RELATIONS NO )
	set( DOXYGEN_HAVE_DOT YES )
	set( DOXYGEN_CLASS_GRAPH YES )
	set( DOXYGEN_CALL_GRAPH YES )
	set( DOXYGEN_CALLER_GRAPH YES )
	set( DOXYGEN_COLLABORATION_GRAPH YES )
	set( DOXYGEN_BUILTIN_STL_SUPPORT YES )
	set( DOXYGEN_EXTRACT_PRIVATE YES )
	set( DOXYGEN_EXTRACT_PACKAGE YES )
	set( DOXYGEN_EXTRACT_STATIC YES )
	set( DOXYGEN_EXTRACT_LOCALMETHODS YES )
	set( DOXYGEN_UML_LOOK YES )
	set( DOXYGEN_UML_LIMIT_NUM_FIELDS 50 )
	set( DOXYGEN_TEMPLATE_RELATIONS YES )
	set( DOXYGEN_DOT_GRAPH_MAX_NODES 100 )
	set( DOXYGEN_MAX_DOT_GRAPH_DEPTH 0 )
	set( DOXYGEN_DOT_TRANSPARENT YES )
81
	set( DOXYGEN_EXCLUDE_PATTERNS *.f90 )
Remi Perenon's avatar
Remi Perenon committed
82
83
84
85
86
	doxygen_add_docs( doxygen ${CMAKE_CURRENT_SOURCE_DIR} )
else (DOXYGEN_FOUND)
  message("Doxygen is not installed - no documentation will be generated")
endif (DOXYGEN_FOUND)

Remi Perenon's avatar
Remi Perenon committed
87
88
89
#################################
# Install section
#################################
90
set_target_properties(${LIBRARY_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${LIBRARY_NAME})
Remi Perenon's avatar
Remi Perenon committed
91
92
93
94
95
96
97
98
99
100
101
102
103
if(APPLE)
    set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".so")
elseif(WIN32)
    set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".pyd")
endif()

# 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)
endif()
Remi Perenon's avatar
Remi Perenon committed
104

Remi Perenon's avatar
Remi Perenon committed
105
# Installing example files
Remi Perenon's avatar
Remi Perenon committed
106
107
108
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Examples" DESTINATION ${PYTHON_API_PREFIX} FILES_MATCHING PATTERN "*.py")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Examples/Data" DESTINATION ${PYTHON_API_PREFIX}/Examples FILES_MATCHING PATTERN "*.cfl" PATTERN "*.cif")

Remi Perenon's avatar
Remi Perenon committed
109
# Installing tests files
Remi Perenon's avatar
Remi Perenon committed
110
111
112
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Tests" DESTINATION ${PYTHON_API_PREFIX} FILES_MATCHING PATTERN "*.py")

# Installing documentation files
113
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html" DESTINATION ${PYTHON_API_PREFIX}/Doc OPTIONAL)