]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add GTest.cmake & PythonAPI.cmake and use it in CMakeLists.txt
authorspo <sergey.pokhodenko@opencascade.com>
Thu, 26 May 2016 13:02:51 +0000 (16:02 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:01 +0000 (14:41 +0300)
CMakeCommon/GTest.cmake [new file with mode: 0644]
CMakeCommon/PythonAPI.cmake [new file with mode: 0644]
src/ConstructionAPI/CMakeLists.txt
src/ConstructionAPI/Test/CMakeLists.txt

diff --git a/CMakeCommon/GTest.cmake b/CMakeCommon/GTest.cmake
new file mode 100644 (file)
index 0000000..448ba61
--- /dev/null
@@ -0,0 +1,24 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+cmake_minimum_required (VERSION 2.6)
+
+include(FindGTest)
+
+
+#FIND_PACKAGE(GTest REQUIRED)
+#INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
+
+#FIND_PACKAGE(GMock REQUIRED)
+#INCLUDE_DIRECTORIES(${GMOCK_INCLUDE_DIRS})
+
+
+# GCC 4.4.6 does not support some C++11 features used by GMock 
+add_definitions(-DGTEST_LANG_CXX11=0)
+
+include_directories(
+    $ENV{GTEST_ROOT}/googletest/include
+    $ENV{GTEST_ROOT}/googlemock/include
+    )
+    
+set(GTEST_LIBRARY $ENV{GTEST_ROOT}/googlemock/make/gmock_main.a)
+  
\ No newline at end of file
diff --git a/CMakeCommon/PythonAPI.cmake b/CMakeCommon/PythonAPI.cmake
new file mode 100644 (file)
index 0000000..e63cd58
--- /dev/null
@@ -0,0 +1,11 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+set(CMAKE_SWIG_FLAGS "-Wall")
+
+# For doxyhelp.i
+include_directories(
+  ${PROJECT_BINARY_DIR}/doc/swig
+)
index 8faa88b4397e00a79f203709380149d82dd7c949..ef8fcb5ea807f4469fad30a46947dd491015d8ca 100644 (file)
@@ -1,12 +1,6 @@
 ## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
 INCLUDE(Common)
-INCLUDE(UnitTest)
-
-FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(${SWIG_USE_FILE})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
-
 
 SET(PROJECT_HEADERS
     ConstructionAPI.h
@@ -22,24 +16,21 @@ SET(PROJECT_LIBRARIES
     ModelHighAPI
     )
 
-ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${CAS_DEFINITIONS})
-ADD_LIBRARY(ConstructionAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-
-SET(CMAKE_SWIG_FLAGS "-Wall")
-
-SET_SOURCE_FILES_PROPERTIES(ConstructionAPI.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(ConstructionAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-
 INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/ModelAPI
     ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
     )
 
+ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(ConstructionAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 TARGET_LINK_LIBRARIES(ConstructionAPI ${PROJECT_LIBRARIES})
 
-SET(SWIG_SCRIPTS
-    ${CMAKE_CURRENT_BINARY_DIR}/ConstructionAPI.py
-    )
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(ConstructionAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(ConstructionAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
 
 SET(SWIG_LINK_LIBRARIES
     ConstructionAPI
@@ -62,7 +53,11 @@ ENDIF(WIN32)
 
 INSTALL(TARGETS _ConstructionAPI DESTINATION ${SHAPER_INSTALL_SWIG})
 INSTALL(TARGETS ConstructionAPI DESTINATION ${SHAPER_INSTALL_BIN})
-INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ConstructionAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
+
+# Tests
+
+INCLUDE(UnitTest)
 
 ADD_UNIT_TESTS(
     TestPoint.py
index ec2e920dacc716f9a26b5df732eb6857565bcd68..bbc44a46a0a8bfd2600ff968bfc0b5f6c15e7da7 100644 (file)
@@ -1,45 +1,28 @@
 ## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
-add_definitions(-DGTEST_LANG_CXX11=0)
+include(GTest)
 
-INCLUDE(FindGTest)
-#FIND_PACKAGE(GTest REQUIRED)
-#INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
+include_directories(
+  ${PROJECT_SOURCE_DIR}/src/Events
+  ${PROJECT_SOURCE_DIR}/src/ModelAPI
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+  ${PROJECT_SOURCE_DIR}/src/ConstructionAPI
+)
 
-#FIND_PACKAGE(GMock REQUIRED)
-#INCLUDE_DIRECTORIES(${GMOCK_INCLUDE_DIRS})
+set(PROJECT_SOURCES
+  TestPoint.cpp
+)
 
-INCLUDE_DIRECTORIES(
-    ${PROJECT_SOURCE_DIR}/src/Events
-    ${PROJECT_SOURCE_DIR}/src/ModelAPI
-    ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
-  
-    $ENV{GTEST_ROOT}/googletest/include
-    $ENV{GTEST_ROOT}/googlemock/include
-    )
+set(PROJECT_LIBRARIES
+  ModelAPI
+  ModelHighAPI
+  ConstructionAPI
+)
 
-SET(TEST_LIBRARIES
-    ModelAPI
-    ModelHighAPI
-    ConstructionAPI
-    )
+set(PACKAGE_NAME "ConstructionAPI")
+set(TARGET_NAME "Test${PACKAGE_NAME}")
 
-SET(PACKAGE_NAME "ConstructionAPI")
-SET(TEST_NAME "${PACKAGE_NAME}_GTest")
-SET(TARGET_NAME "Test${PACKAGE_NAME}")
+add_executable(${TARGET_NAME} ${PROJECT_SOURCES})
+target_link_libraries(${TARGET_NAME} ${PROJECT_LIBRARIES} ${GTEST_LIBRARY})
 
-ADD_EXECUTABLE(${TARGET_NAME}
-    TestPoint.cpp
-    )
-
-TARGET_LINK_LIBRARIES(${TARGET_NAME} 
-    ${TEST_LIBRARIES}
-    
-    $ENV{GTEST_ROOT}/googlemock/make/gmock_main.a
-    )
-
-GET_TARGET_PROPERTY(TEST_SOURCES ${TARGET_NAME} SOURCES)
-GTEST_ADD_TESTS(${CMAKE_BINARY_DIR}/bin/${TARGET_NAME} 
-    ""
-    ${TEST_SOURCES}
-    )
\ No newline at end of file
+GTEST_ADD_TESTS(${CMAKE_BINARY_DIR}/bin/${TARGET_NAME} "" ${PROJECT_SOURCES})