1 #-----------------------------------------------------------------------------
2 # BUILDS AND INSTALLS THE LIBRARY BBTK
3 #-----------------------------------------------------------------------------
6 #-----------------------------------------------------------------------------
8 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Test if compiler defines the pseudo-macro __FUNCTION__
13 IF("BBTK_COMPILER_HAS_FUNCTION" MATCHES "^BBTK_COMPILER_HAS_FUNCTION$")
14 MESSAGE(STATUS "Checking support for __FUNCTION__ in compiler")
15 TRY_COMPILE(BBTK_COMPILER_HAS_FUNCTION
16 ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp/Function
17 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bbtkTestFUNCTION.cxx
18 OUTPUT_VARIABLE OUTPUT)
19 IF(BBTK_COMPILER_HAS_FUNCTION)
20 MESSAGE(STATUS "Checking support for __FUNCTION__ -- yes")
21 SET(BBTK_COMPILER_HAS_FUNCTION 1 CACHE INTERNAL "Support for extension C __FUNCTION__")
22 WRITE_FILE(${CMAKE_CURRENT_BINARY_DIR}/CMakeOutput.log
23 "Determining if the C compiler supports __FUNCTION__ "
24 "passed with the following output:\n"
26 ELSE(BBTK_COMPILER_HAS_FUNCTION)
27 MESSAGE(STATUS "Checking support for __FUNCTION__ -- no")
28 SET(BBTK_COMPILER_HAS_FUNCTION 0 CACHE INTERNAL "Support for extension C __FUNCTION__")
29 WRITE_FILE(${CMAKE_CURRENT_BINARY_DIR}/CMakeError.log
30 "Determining if the C compiler supports __FUNCTION__ "
31 "failed with the following output:\n"
33 ENDIF(BBTK_COMPILER_HAS_FUNCTION)
34 ENDIF("BBTK_COMPILER_HAS_FUNCTION" MATCHES "^BBTK_COMPILER_HAS_FUNCTION$")
35 #-----------------------------------------------------------------------------
37 #-----------------------------------------------------------------------------
38 # Test is compiler support istringstream
39 IF("BBTK_TEST_ISTRINGSTREAM" MATCHES "^BBTK_TEST_ISTRINGSTREAM$")
40 MESSAGE(STATUS "Checking istringstream")
41 TRY_RUN(BBTK_TEST_ISTRINGSTREAM BBTK_TEST_ISTRINGSTREAM_COMPILED
42 ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp/
43 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bbtkTestIstringStream.cxx)
44 IF(BBTK_TEST_ISTRINGSTREAM_COMPILED)
45 IF(BBTK_TEST_ISTRINGSTREAM)
46 MESSAGE(STATUS "Checking istringstream works -- yes")
47 SET(BBTK_TEST_ISTRINGSTREAM 1 CACHE INTERNAL "Whether istringstream works.")
48 ELSE(BBTK_TEST_ISTRINGSTREAM)
49 MESSAGE(STATUS "Checking istringstream works -- no")
50 SET(BBTK_TEST_ISTRINGSTREAM 0 CACHE INTERNAL "Whether istringstream works.")
51 ENDIF(BBTK_TEST_ISTRINGSTREAM)
52 ELSE(BBTK_TEST_ISTRINGSTREAM_COMPILED)
53 MESSAGE(STATUS "Checking istringstream -- failed")
54 ENDIF(BBTK_TEST_ISTRINGSTREAM_COMPILED)
55 ENDIF("BBTK_TEST_ISTRINGSTREAM" MATCHES "^BBTK_TEST_ISTRINGSTREAM$")
56 #-----------------------------------------------------------------------------
58 #-----------------------------------------------------------------------------
59 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
60 CHECK_INCLUDE_FILE("stdint.h" CMAKE_HAVE_STDINT_H)
61 IF(UNIX) #Avoid polluting Win32 cmakecache
62 CHECK_INCLUDE_FILE("inttypes.h" CMAKE_HAVE_INTTYPES_H)
64 CHECK_INCLUDE_FILE("termios.h" CMAKE_HAVE_TERMIOS_H)
66 # Special Time support, two conventions: *NIX vs Win32
67 CHECK_INCLUDE_FILE("sys/times.h" CMAKE_HAVE_SYS_TIMES_H)
68 CHECK_INCLUDE_FILE("sys/timeb.h" CMAKE_HAVE_SYS_TIMEB_H)
69 #-----------------------------------------------------------------------------
73 #-----------------------------------------------------------------------------
74 # bbtk library dependencies
75 #-----------------------------------------------------------------------------
77 #-----------------------------------------------------------------------------
79 OPTION(BBTK_USE_WXWIDGETS "Build bbtk library and applications in graphical mode using the wxWidgets library" OFF)
81 IF(BBTK_USE_WXWIDGETS)
82 SET(USE_WXWIDGETS ON CACHE BOOL "Use WxWidgets" FORCE)
84 # INCLUDE(cmake/FIND_AND_USE_WXWIDGETS.cmake)
85 # FIND_AND_USE_WXWIDGETS()
86 # ADD_DEF( _USE_WXWIDGETS_ )
87 SET(BBTK_LINK_LIBRARIES
88 ${BBTK_LINK_LIBRARIES}
89 ${BBTK_WXWIDGETS_LIBRARIES}
91 ENDIF(BBTK_USE_WXWIDGETS)
92 #-----------------------------------------------------------------------------
94 #-----------------------------------------------------------------------------
95 # On unix systems, need to link against dl for dynamic librairies open/close
97 SET(BBTK_LINK_LIBRARIES
98 ${BBTK_LINK_LIBRARIES}
101 #-----------------------------------------------------------------------------
103 #-----------------------------------------------------------------------------
104 # EO bbtk library dependencies
105 #-----------------------------------------------------------------------------
113 #-----------------------------------------------------------------------------
114 # Generates the bbtkConfigure.h file
115 #-----------------------------------------------------------------------------
117 #-----------------------------------------------------------------------------
118 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bbtkConfigure.h.in
119 ${CMAKE_CURRENT_BINARY_DIR}/bbtkConfigure.h
122 #-----------------------------------------------------------------------------
124 #-----------------------------------------------------------------------------
125 IF(NOT BBTK_INSTALL_NO_DEVELOPMENT)
126 INSTALL_FILES(/include/bbtk FILES bbtkConfigure.h)
127 ENDIF(NOT BBTK_INSTALL_NO_DEVELOPMENT)
128 #-----------------------------------------------------------------------------
130 #-----------------------------------------------------------------------------
131 # Add the path to current dir for apps to find bbtkConfigure.h
132 # LG : already done in upper dir
133 #INCLUDE_DIRECTORIES(
134 # ${CMAKE_CURRENT_BINARY_DIR} #for bbtkConfigure.h
136 #-----------------------------------------------------------------------------
138 #-----------------------------------------------------------------------------
139 # EO Generates the bbtkConfigure.h file
140 #-----------------------------------------------------------------------------
148 #-----------------------------------------------------------------------------
149 # bbtk library creation
150 #-----------------------------------------------------------------------------
151 # Symbols must be exported (Windows)
152 ADD_DEF(BBTK_EXPORT_SYMBOLS)
154 #-----------------------------------------------------------------------------
156 FILE(GLOB SOURCES "." "*.cxx" "*.cpp")
157 FILE(GLOB SOURCES_H "." "*.h" )
158 #-----------------------------------------------------------------------------
160 ADD_LIBRARY(bbtk SHARED ${SOURCES} ${SOURCES_H})
161 #-----------------------------------------------------------------------------
162 TARGET_LINK_LIBRARIES(bbtk ${BBTK_LINK_LIBRARIES})
163 #-----------------------------------------------------------------------------
166 # for gnu linker : version script used to define exported symbols
167 #SET_TARGET_PROPERTIES(bbtk PROPERTIES
168 # LINK_FLAGS_DEBUG -Wl,--version-script=bbtk.map)
169 #SET_TARGET_PROPERTIES(bbtk PROPERTIES
170 # LINK_FLAGS_RELEASE -Wl,--version-script=bbtk.map)
172 #-----------------------------------------------------------------------------
174 #-----------------------------------------------------------------------------
175 # EO bbtk library creation
176 #-----------------------------------------------------------------------------
183 #-----------------------------------------------------------------------------
184 # bbtk library installation
185 #-----------------------------------------------------------------------------
187 #-----------------------------------------------------------------------------
188 INSTALL_FILES(/include/bbtk "\\.h$")
189 INSTALL_TARGETS(/lib bbtk)
190 #-----------------------------------------------------------------------------
193 #-----------------------------------------------------------------------------
194 # TO DO : create FindBBTK.cmake
195 #INCLUDE(InstallFindBBTK.cmake)
196 #-----------------------------------------------------------------------------
199 #-----------------------------------------------------------------------------
200 # EO bbtk library installation
201 #-----------------------------------------------------------------------------
205 #-----------------------------------------------------------------------------
207 #-----------------------------------------------------------------------------