Salome HOME
Merge from V6_3_BR 15/07/2011
[modules/kernel.git] / salome_adm / cmake_files / FindCPPUNIT.cmake
1 # Copyright (C) 2007-2011  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   ELSE(WITH_CPPUNIT)
56     SET(CPPUNIT_ROOT_USER $ENV{CPPUNIT_ROOT})
57   ENDIF(WITH_CPPUNIT)
58 ENDIF(CPPUNIT_STATUS)
59
60 # -----
61
62 IF(CPPUNIT_STATUS)
63   IF(CPPUNIT_ROOT_USER)
64     SET(CPPUNIT_FIND_PATHS_OPTION NO_DEFAULT_PATH)
65   ELSE(CPPUNIT_ROOT_USER)
66     SET(CPPUNIT_FIND_PATHS_OPTION)
67   ENDIF(CPPUNIT_ROOT_USER)
68 ENDIF(CPPUNIT_STATUS)
69
70 # -----
71
72 IF(CPPUNIT_STATUS)
73   IF(CPPUNIT_ROOT_USER)
74     SET(CPPUNIT_INCLUDE_PATHS ${CPPUNIT_ROOT_USER} ${CPPUNIT_ROOT_USER}/include)
75   ELSE(CPPUNIT_ROOT_USER)
76     SET(CPPUNIT_INCLUDE_PATHS)
77   ENDIF(CPPUNIT_ROOT_USER)
78   SET(CPPUNIT_INCLUDE_TO_FIND cppunit/extensions/HelperMacros.h)
79   FIND_PATH(CPPUNIT_INCLUDE_DIR ${CPPUNIT_INCLUDE_TO_FIND} PATHS ${CPPUNIT_INCLUDE_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
80   IF(CPPUNIT_INCLUDE_DIR)
81     IF(CPPUNIT_ROOT_USER)
82       SET(CPPUNIT_INCLUDES -I${CPPUNIT_INCLUDE_DIR})
83     ENDIF(CPPUNIT_ROOT_USER)
84     MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} found in ${CPPUNIT_INCLUDE_DIR}")
85   ELSE(CPPUNIT_INCLUDE_DIR)
86     SET(CPPUNIT_STATUS 0)
87     IF(CPPUNIT_ROOT_USER)
88       MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} not found in ${CPPUNIT_INCLUDE_PATHS}, check your CPPUNIT installation.")
89     ELSE(CPPUNIT_ROOT_USER)
90       MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} not found on system, try to use WITH_CPPUNIT option or CPPUNIT_ROOT environment variable.")
91     ENDIF(CPPUNIT_ROOT_USER)
92   ENDIF(CPPUNIT_INCLUDE_DIR)
93 ENDIF(CPPUNIT_STATUS)
94
95 # ----
96
97 IF(CPPUNIT_STATUS)
98   IF(CPPUNIT_ROOT_USER)
99     SET(CPPUNIT_LIB_PATHS ${CPPUNIT_ROOT_USER}/lib)
100   ELSE(CPPUNIT_ROOT_USER)
101     SET(CPPUNIT_LIB_PATHS)
102   ENDIF(CPPUNIT_ROOT_USER)
103 ENDIF(CPPUNIT_STATUS)
104
105 IF(CPPUNIT_STATUS)
106   IF(WINDOWS)
107     IF(CMAKE_BUILD_TYPE STREQUAL Debug)
108       FIND_LIBRARY(CPPUNIT_LIB cppunitd_dll PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
109     ELSE(CMAKE_BUILD_TYPE STREQUAL Debug)
110       FIND_LIBRARY(CPPUNIT_LIB cppunit_dll PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
111     ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
112   ELSE(WINDOWS)
113     FIND_LIBRARY(CPPUNIT_LIB cppunit PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION})
114   ENDIF(WINDOWS)
115   SET(CPPUNIT_LIBS)
116   IF(CPPUNIT_LIB)
117     SET(CPPUNIT_LIBS ${CPPUNIT_LIBS} ${CPPUNIT_LIB})
118     MESSAGE(STATUS "cppunit lib found: ${CPPUNIT_LIB}")
119   ELSE(CPPUNIT_LIB)
120     SET(CPPUNIT_STATUS 0)
121     IF(CPPUNIT_ROOT_USER)
122       MESSAGE(STATUS "cppunit lib not found in ${CPPUNIT_LIB_PATHS}, check your CPPUNIT installation.")
123     ELSE(CPPUNIT_ROOT_USER)
124       MESSAGE(STATUS "cppunit lib not found on system, try to use WITH_CPPUNIT option or CPPUNIT_ROOT environment variable.")
125     ENDIF(CPPUNIT_ROOT_USER)
126   ENDIF(CPPUNIT_LIB)
127 ENDIF(CPPUNIT_STATUS)
128
129 # ----
130
131 IF(CPPUNIT_STATUS)
132   SET(CPPUNIT_IS_OK 1)
133   IF(WINDOWS)
134     SET(CPPUNIT_INCLUDES ${CPPUNIT_INCLUDES} -DCPPUNIT_DLL)
135   ENDIF(WINDOWS)
136 ELSE(CPPUNIT_STATUS)
137   IF(CPPUNIT_IS_MANDATORY)
138     MESSAGE(FATAL_ERROR "cppunit not found ... mandatory ... abort")
139   ELSE(CPPUNIT_IS_MANDATORY)
140     MESSAGE(STATUS "cppunit not found ... optional ... disabled")
141   ENDIF(CPPUNIT_IS_MANDATORY)
142 ENDIF(CPPUNIT_STATUS)
143
144 # ------