Salome HOME
8a076758eaba308db611d0dd3c0814be4849a472
[tools/adao_interface.git] / CMakeLists.txt
1 # Copyright (C) 2019 EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Author: Anthony Geay, anthony.geay@edf.fr, EDF R&D
20
21 cmake_minimum_required(VERSION 2.6)
22 project(AdaoExchangeLayer)
23
24 ##
25
26 set(BUILD_SHARED_LIBS TRUE)
27 set(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
28 if(EXISTS ${CONFIGURATION_ROOT_DIR})
29   list(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
30   include(SalomeMacros)
31   include(SalomeSetupPlatform)
32 else(EXISTS ${CONFIGURATION_ROOT_DIR})
33   message(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
34 endif(EXISTS ${CONFIGURATION_ROOT_DIR})
35
36 ##
37
38 option(AEL_ENABLE_TESTS "Build tests (default ON)." ON)
39 if(AEL_ENABLE_TESTS)
40   if(EXISTS ${PY2CPP_ROOT_DIR})
41     set(PY2CPP_ROOT_DIR $ENV{PY2CPP_ROOT_DIR} CACHE PATH "Path to Py2cpp")
42     set(Py2cpp_DIR "${PY2CPP_ROOT_DIR}/lib/cmake/py2cpp")
43     find_package(Py2cpp REQUIRED)
44     get_target_property(PY2CPP_INCLUDE_DIR py2cpp INTERFACE_INCLUDE_DIRECTORIES)
45     get_target_property(PY2CPP_LIB py2cpp IMPORTED_LOCATION_RELEASE)
46     find_package(SalomeCppUnit)
47   else(EXISTS ${PY2CPP_ROOT_DIR})
48     message(FATAL_ERROR "PY2CPP declared as enabled whereas not found !")
49   endif(EXISTS ${PY2CPP_ROOT_DIR})
50 endif(AEL_ENABLE_TESTS)
51
52 ##
53
54 find_package(SalomePythonInterp REQUIRED)
55 find_package(SalomePythonLibs REQUIRED)
56
57 ##
58
59 include_directories(
60   ${PYTHON_INCLUDE_DIRS}
61   ${PY2CPP_INCLUDE_DIR}
62   ${CPPUNIT_INCLUDE_DIRS}
63   )
64 set(adaoexchange_SOURCES AdaoExchangeLayer.cxx AdaoModelKeyVal.cxx)
65 add_library(adaoexchange ${adaoexchange_SOURCES})
66 target_link_libraries(adaoexchange ${PYTHON_LIBRARIES})
67 install(FILES AdaoExchangeLayer.hxx PyObjectRAII.hxx AdaoExchangeLayerException.hxx AdaoModelKeyVal.hxx DESTINATION include)
68 install(TARGETS adaoexchange DESTINATION lib)
69
70 ##
71
72 if(AEL_ENABLE_TESTS)
73   add_executable(TestAdaoExchange TestAdaoExchange.cxx)
74   target_link_libraries(TestAdaoExchange adaoexchange ${PY2CPP_LIB} ${CPPUNIT_LIBRARIES})
75   install(TARGETS TestAdaoExchange DESTINATION bin)
76 endif(AEL_ENABLE_TESTS)