summaryrefslogtreecommitdiff
path: root/python/gras/CMakeLists.txt
blob: dda4934e1113c60af866669a70f8533895d95b9d (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
########################################################################
# Include swig generation macros
########################################################################
find_package(SWIG)
if(NOT SWIG_FOUND)
    return()
endif()

find_package(PythonLibs)
if(NOT PYTHONLIBS_FOUND)
    return()
endif()

include(UseSWIG)
include(GrPython)

########################################################################
# Local includes
########################################################################
list(APPEND CMAKE_SWIG_INC_FLAGS "-I${PMC_SOURCE_DIR}/include")
list(APPEND CMAKE_SWIG_INC_FLAGS "-I${GRAS_SOURCE_DIR}/include")
include_directories(${GRAS_INCLUDE_DIRS})

########################################################################
# Python library setup
########################################################################
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(${PYTHON_INCLUDE_DIRS})

########################################################################
# Finding Boost headers
########################################################################
find_package(Boost)
include_directories(${Boost_INCLUDE_DIRS})

########################################################################
# swig build modules
########################################################################
set(gras_swig_modules
    GRAS_Tags
    GRAS_TimeTag
    GRAS_Element
    GRAS_Factory
    GRAS_Block
    GRAS_HierBlock
    GRAS_PyBlock
    GRAS_PyHierBlocks
    GRAS_TopBlock
    GRAS_ThreadPool
    GRAS_SBuffer
)

file(GLOB pmc_i_files "${PMC_SOURCE_DIR}/include/PMC/*.i")
file(GLOB gras_i_files "${GRAS_SOURCE_DIR}/include/gras/*.i")

foreach(gras_swig_module ${gras_swig_modules})
    message(STATUS "Configuring swig python module ${gras_swig_module}...")

    #set the C++ property on the swig .i file so it builds
    set_source_files_properties(${gras_swig_module}.i PROPERTIES CPLUSPLUS ON)

    set(CMAKE_SWIG_FLAGS -fvirtual -module ${gras_swig_module} ${CMAKE_SWIG_INC_FLAGS})
    set(SWIG_MODULE_${gras_swig_module}_EXTRA_DEPS ${pmc_i_files} ${gras_i_files})
    SWIG_ADD_MODULE(${gras_swig_module} python ${gras_swig_module}.i)
    SWIG_LINK_LIBRARIES(${gras_swig_module} ${GRAS_LIBRARIES} ${PYTHON_LIBRARIES})

    install(
        TARGETS ${SWIG_MODULE_${gras_swig_module}_REAL_NAME}
        DESTINATION ${GR_PYTHON_DIR}/gras
        COMPONENT ${GRAS_COMP_PYTHON}
    )
    install(
        FILES ${CMAKE_CURRENT_BINARY_DIR}/${gras_swig_module}.py
        DESTINATION ${GR_PYTHON_DIR}/gras
        COMPONENT ${GRAS_COMP_PYTHON}
    )
endforeach(gras_swig_module)

########################################################################
# install other python files
########################################################################
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/GRAS_Loader.py
    ${CMAKE_CURRENT_BINARY_DIR}/GRAS_Loader.py
@ONLY)

GR_PYTHON_INSTALL(
    FILES
    __init__.py
    GRAS_Utils.py
    ${CMAKE_CURRENT_BINARY_DIR}/GRAS_Loader.py
    DESTINATION ${GR_PYTHON_DIR}/gras
    COMPONENT ${GRAS_COMP_PYTHON}
)