Salome HOME
merge from BR_KERNEL_REFACTORING
[modules/yacs.git] / salome_adm / cmake_files / FindCPPUNIT.cmake
1 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 # ------
24
25 MESSAGE(STATUS "Check for cppunit ...")
26
27 # ------
28
29 IF(CPPUNIT_IS_MANDATORY STREQUAL 0)
30   SET(CPPUNIT_IS_MANDATORY 0)
31   SET(CPPUNIT_IS_OPTIONAL 1)
32 ENDIF(CPPUNIT_IS_MANDATORY STREQUAL 0)
33 IF(CPPUNIT_IS_OPTIONAL STREQUAL 0)
34   SET(CPPUNIT_IS_MANDATORY 1)
35   SET(CPPUNIT_IS_OPTIONAL 0)
36 ENDIF(CPPUNIT_IS_OPTIONAL STREQUAL 0)
37 IF(NOT CPPUNIT_IS_MANDATORY AND NOT CPPUNIT_IS_OPTIONAL)
38   SET(CPPUNIT_IS_MANDATORY 0)
39   SET(CPPUNIT_IS_OPTIONAL 1)
40 ENDIF(NOT CPPUNIT_IS_MANDATORY AND NOT CPPUNIT_IS_OPTIONAL)
41
42 # ------
43
44 SET(CPPUNIT_STATUS 1)
45 IF(WITHOUT_CPPUNIT OR WITH_CPPUNIT STREQUAL 0)
46   SET(CPPUNIT_STATUS 0)
47   MESSAGE(STATUS "cppunit disabled from command line.")
48 ENDIF(WITHOUT_CPPUNIT OR WITH_CPPUNIT STREQUAL 0)
49
50 # ------
51
52 IF(CPPUNIT_STATUS)
53   IF(WITH_CPPUNIT)
54     SET(CPPUNIT_ROOT_USER ${WITH_CPPUNIT})
55   ENDIF(WITH_CPPUNIT)
56   IF(NOT CPPUNIT_ROOT_USER)
57     SET(CPPUNIT_ROOT_USER $ENV{CPPUNIT_ROOT})
58   ENDIF(NOT CPPUNIT_ROOT_USER)
59   IF(NOT CPPUNIT_ROOT_USER)
60     SET(CPPUNIT_ROOT_USER $ENV{CPPUNITHOME})
61   ENDIF(NOT CPPUNIT_ROOT_USER)
62 ENDIF(CPPUNIT_STATUS)
63
64 # -----
65
66 IF(CPPUNIT_STATUS)
67   IF(CPPUNIT_ROOT_USER)
68     SET(CPPUNIT_FIND_PATHS_OPTION NO_DEFAULT_PATH)
69   ELSE(CPPUNIT_ROOT_USER)
70     SET(CPPUNIT_FIND_PATHS_OPTION)
71   ENDIF(CPPUNIT_ROOT_USER)
72 ENDIF(CPPUNIT_STATUS)
73
74 # -----
75
76 IF(CPPUNIT_STATUS)
77   IF(CPPUNIT_ROOT_USER)
78     SET(CPPUNIT_INCLUDE_PATHS ${CPPUNIT_ROOT_USER} ${CPPUNIT_ROOT_USER}/include)
79   ELSE(CPPUNIT_ROOT_USER)
80     SET(CPPUNIT_INCLUDE_PATHS)
81   ENDIF(CPPUNIT_ROOT_USER)
82   SET(CPPUNIT_INCLUDE_TO_FIND cppunit/extensions/HelperMacros.h)
83   FIND_PATH(CPPUNIT_INCLUDE_DIR ${CPPUNIT_INCLUDE_TO_FIND} PATHS ${CPPUNIT_INCLUDE_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
84   IF(CPPUNIT_INCLUDE_DIR)
85     IF(CPPUNIT_ROOT_USER)
86       SET(CPPUNIT_INCLUDES -I${CPPUNIT_INCLUDE_DIR})# to be removed
87       IF(${CPPUNIT_INCLUDE_DIR} STREQUAL /usr/include)
88         SET(CPPUNIT_INCLUDE_DIRS)
89       ELSE(${CPPUNIT_INCLUDE_DIR} STREQUAL /usr/include)
90         SET(CPPUNIT_INCLUDE_DIRS ${CPPUNIT_INCLUDE_DIR})
91       ENDIF(${CPPUNIT_INCLUDE_DIR} STREQUAL /usr/include)
92     ENDIF(CPPUNIT_ROOT_USER)
93     MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} found in ${CPPUNIT_INCLUDE_DIR}")
94   ELSE(CPPUNIT_INCLUDE_DIR)
95     SET(CPPUNIT_STATUS 0)
96     IF(CPPUNIT_ROOT_USER)
97       MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} not found in ${CPPUNIT_INCLUDE_PATHS}, check your CPPUNIT installation.")
98     ELSE(CPPUNIT_ROOT_USER)
99       MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} not found on system, try to use WITH_CPPUNIT option or CPPUNIT_ROOT (or CPPUNITHOME) environment variable.")
100     ENDIF(CPPUNIT_ROOT_USER)
101   ENDIF(CPPUNIT_INCLUDE_DIR)
102 ENDIF(CPPUNIT_STATUS)
103
104 # ----
105
106 IF(CPPUNIT_STATUS)
107   IF(CPPUNIT_ROOT_USER)
108     SET(CPPUNIT_LIB_PATHS ${CPPUNIT_ROOT_USER}/lib)
109   ELSE(CPPUNIT_ROOT_USER)
110     SET(CPPUNIT_LIB_PATHS)
111   ENDIF(CPPUNIT_ROOT_USER)
112 ENDIF(CPPUNIT_STATUS)
113
114 IF(CPPUNIT_STATUS)
115   IF(WINDOWS)
116     IF(CMAKE_BUILD_TYPE STREQUAL Debug)
117       FIND_LIBRARY(CPPUNIT_LIB cppunitd_dll PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
118     ELSE(CMAKE_BUILD_TYPE STREQUAL Debug)
119       FIND_LIBRARY(CPPUNIT_LIB cppunit_dll PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
120     ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
121   ELSE(WINDOWS)
122     FIND_LIBRARY(CPPUNIT_LIB cppunit PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
123   ENDIF(WINDOWS)
124   SET(CPPUNIT_LIBS)
125   IF(CPPUNIT_LIB)
126     SET(CPPUNIT_LIBS ${CPPUNIT_LIBS} ${CPPUNIT_LIB})
127     MESSAGE(STATUS "cppunit lib found: ${CPPUNIT_LIB}")
128   ELSE(CPPUNIT_LIB)
129     SET(CPPUNIT_STATUS 0)
130     IF(CPPUNIT_ROOT_USER)
131       MESSAGE(STATUS "cppunit lib not found in ${CPPUNIT_LIB_PATHS}, check your CPPUNIT installation.")
132     ELSE(CPPUNIT_ROOT_USER)
133       MESSAGE(STATUS "cppunit lib not found on system, try to use WITH_CPPUNIT option or CPPUNIT_ROOT environment variable.")
134     ENDIF(CPPUNIT_ROOT_USER)
135   ENDIF(CPPUNIT_LIB)
136 ENDIF(CPPUNIT_STATUS)
137
138 # ----
139
140 IF(CPPUNIT_STATUS)
141   SET(CPPUNIT_IS_OK 1)
142   SET(CPPUNIT_DEFINITIONS)
143   IF(WINDOWS)
144     SET(CPPUNIT_INCLUDES ${CPPUNIT_INCLUDES} -DCPPUNIT_DLL)
145     SET(CPPUNIT_DEFINITIONS "-DCPPUNIT_DLL")
146   ENDIF(WINDOWS)
147 ELSE(CPPUNIT_STATUS)
148   IF(CPPUNIT_IS_MANDATORY)
149     MESSAGE(FATAL_ERROR "cppunit not found ... mandatory ... abort")
150   ELSE(CPPUNIT_IS_MANDATORY)
151     MESSAGE(STATUS "cppunit not found ... optional ... disabled")
152   ENDIF(CPPUNIT_IS_MANDATORY)
153 ENDIF(CPPUNIT_STATUS)
154
155 # ------