Very basic but functional (at least on linux with gcc) support

for CMake build system
. 
It is strongly recomended to use out-of-source build to preserve
original Poco makefiles.

http://www.cmake.org/Wiki/CMake_FAQ#Out-of-source_build_trees

I have tested unix makefile generating and Eclipse CDT4 generating.

Supported are static/dynamic and debug/release targets. 
On now only core libs are included: CppUnit, Foundation,
Data, Data/SQLite, Util, Net and XML. But autodetection
of OpenSSL, MySQL and ODBC is working OK already.

CPack and CTest nor library install still doesn't work, only building.

This is only the start.
This commit is contained in:
Marian Krivos 2009-02-15 15:49:19 +00:00
parent ec7c34dec4
commit 5b320c2894
10 changed files with 599 additions and 0 deletions

45
CMakeLists.txt Normal file
View File

@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 2.6.0)
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "3")
set(CPACK_PACKAGE_VERSION_PATCH "99")
#set(COMMON_CXX "-Wall -Wno-sign-compare")
set(DEBUG_CXX_FLAGS "${COMMON_CXX} ${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(RELEASE_CXX_FLAGS "${COMMON_CXX} ${CMAKE_CXX_FLAGS_MINSIZEREL}")
# Uncomment from next two lines to force statitc or dynamic library, default is autodetection
if(POCO_STATIC)
set( LIB_MODE STATIC )
else(POCO_STATIC)
set( LIB_MODE SHARED )
endif(POCO_STATIC)
# Set local include path
include_directories( CppUnit/include Foundation/include XML/include Net/include Util/include Data/include )
include(CheckTypeSize)
include(FindCygwin)
include(FindOpenSSL)
include(contrib/cmake/FindMySQL.cmake)
include(contrib/cmake/FindODBC.cmake)
# OS Detection
if(CMAKE_SYSTEM MATCHES "Windows")
add_definitions( -DPOCO_OS_FAMILY_WINDOWS)
else (CMAKE_SYSTEM MATCHES "Windows")
add_definitions( -DPOCO_OS_FAMILY_UNIX )
endif(CMAKE_SYSTEM MATCHES "Windows")
# Standard 'must be' defines
add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
# UTF-8 detection (POCO_WIN32_UTF8)
add_subdirectory(CppUnit)
add_subdirectory(Foundation)
add_subdirectory(XML)
add_subdirectory(Util)
add_subdirectory(Net)
add_subdirectory(Data)

18
CppUnit/CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
set(LIBNAME "CppUnit")
set(LIBNAMED "${LIBNAME}d")
aux_source_directory(src SRCS)
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} )
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} )

22
Data/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
set(LIBNAME "PocoData")
set(LIBNAMED "${LIBNAME}d")
set(SRCS "")
aux_source_directory(src SRCS)
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} PocoFoundation )
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} PocoFoundationd )
add_subdirectory( SQLite )
#add_subdirectory( testsuite )

View File

@ -0,0 +1,25 @@
set(LIBNAME "PocoSQLite")
set(LIBNAMED "${LIBNAME}d")
include_directories( include src )
set(SRCS "")
aux_source_directory(src SRCS)
add_definitions(-DSQLITE_OMIT_UTF16 -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_COMPLETE -DSQLITE_OMIT_TCL_VARIABLE)
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} PocoData )
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} PocoDatad )
#add_subdirectory( testsuite )

200
Foundation/CMakeLists.txt Normal file
View File

@ -0,0 +1,200 @@
set(LIBNAME "PocoFoundation")
set(LIBNAMED "${LIBNAME}d")
set( BASE_SRCS
src/ASCIIEncoding.cpp
src/AbstractObserver.cpp
src/ActiveDispatcher.cpp
src/ArchiveStrategy.cpp
src/AsyncChannel.cpp
src/Base64Decoder.cpp
src/Base64Encoder.cpp
src/BinaryReader.cpp
src/BinaryWriter.cpp
src/Bugcheck.cpp
src/ByteOrder.cpp
src/Channel.cpp
src/Checksum.cpp
src/Condition.cpp
src/Configurable.cpp
src/ConsoleChannel.cpp
src/CountingStream.cpp
src/DateTime.cpp
src/DateTimeFormat.cpp
src/DateTimeFormatter.cpp
src/DateTimeParser.cpp
src/Debugger.cpp
src/DeflatingStream.cpp
src/DigestEngine.cpp
src/DigestStream.cpp
src/DirectoryIterator.cpp
# src/DynamicAny.cpp
# src/DynamicAnyHolder.cpp
src/Environment.cpp
src/ErrorHandler.cpp
src/Event.cpp
src/EventArgs.cpp
src/Exception.cpp
src/FPEnvironment.cpp
src/File.cpp
src/FileChannel.cpp
src/FileStream.cpp
src/FileStreamFactory.cpp
src/Format.cpp
src/Formatter.cpp
src/FormattingChannel.cpp
src/Glob.cpp
src/Hash.cpp
src/HashStatistic.cpp
src/HexBinaryDecoder.cpp
src/HexBinaryEncoder.cpp
src/InflatingStream.cpp
src/Latin1Encoding.cpp
src/Latin9Encoding.cpp
src/LineEndingConverter.cpp
src/LocalDateTime.cpp
src/LogFile.cpp
src/LogStream.cpp
src/Logger.cpp
src/LoggingFactory.cpp
src/LoggingRegistry.cpp
src/MD2Engine.cpp
src/MD4Engine.cpp
src/MD5Engine.cpp
src/Manifest.cpp
src/MemoryPool.cpp
src/Message.cpp
src/Mutex.cpp
src/NamedEvent.cpp
src/NamedMutex.cpp
src/NestedDiagnosticContext.cpp
src/Notification.cpp
src/NotificationCenter.cpp
src/NotificationQueue.cpp
src/NullChannel.cpp
src/NullStream.cpp
src/NumberFormatter.cpp
src/NumberParser.cpp
# src/OpcomChannel.cpp
src/Path.cpp
src/PatternFormatter.cpp
src/Pipe.cpp
src/PipeImpl.cpp
src/PipeStream.cpp
src/Process.cpp
src/PurgeStrategy.cpp
src/RWLock.cpp
src/Random.cpp
src/RandomStream.cpp
src/RefCountedObject.cpp
src/RegularExpression.cpp
src/RotateStrategy.cpp
src/Runnable.cpp
src/SHA1Engine.cpp
src/Semaphore.cpp
src/SharedLibrary.cpp
src/SharedMemory.cpp
src/SignalHandler.cpp
src/SimpleFileChannel.cpp
src/SplitterChannel.cpp
src/Stopwatch.cpp
src/StreamChannel.cpp
src/StreamConverter.cpp
src/StreamCopier.cpp
src/StreamTokenizer.cpp
src/String.cpp
src/StringTokenizer.cpp
src/SynchronizedObject.cpp
src/Task.cpp
src/TaskManager.cpp
src/TaskNotification.cpp
src/TeeStream.cpp
src/TemporaryFile.cpp
src/TextConverter.cpp
src/TextEncoding.cpp
src/TextIterator.cpp
src/Thread.cpp
src/ThreadLocal.cpp
src/ThreadPool.cpp
src/Timer.cpp
src/Timespan.cpp
src/Timestamp.cpp
src/Timezone.cpp
src/Token.cpp
src/URI.cpp
src/URIStreamFactory.cpp
src/URIStreamOpener.cpp
src/UTF16Encoding.cpp
src/UTF8Encoding.cpp
src/UTF8String.cpp
src/UUID.cpp
src/UUIDGenerator.cpp
src/Unicode.cpp
src/UnicodeConverter.cpp
src/Void.cpp
src/Windows1252Encoding.cpp
src/adler32.c
src/compress.c
src/crc32.c
src/deflate.c
src/gzio.c
src/infback.c
src/inffast.c
src/inflate.c
src/inftrees.c
src/pcre_chartables.c
src/pcre_compile.c
src/pcre_exec.c
src/pcre_fullinfo.c
src/pcre_globals.c
src/pcre_maketables.c
src/pcre_newline.c
src/pcre_ord2utf8.c
src/pcre_study.c
src/pcre_tables.c
src/pcre_try_flipped.c
src/pcre_ucd.c
src/pcre_valid_utf8.c
src/pcre_xclass.c
src/pocomsg.mc
src/trees.c
src/zutil.c
)
set(WIN_SRCS
src/EventLogChannel.cpp
src/WindowsConsoleChannel.cpp
)
set(LIN_SRCS
src/SyslogChannel.cpp
)
if(CMAKE_SYSTEM MATCHES "Windows")
set(SRCS ${BASE_SRCS} ${WIN_SRCS})
add_definitions( -DPOCO_NO_FPENVIRONMENT -DPCRE_STATIC)
else (CMAKE_SYSTEM MATCHES "Windows")
set(SRCS ${BASE_SRCS} ${LIN_SRCS})
add_definitions( -DPCRE_STATIC)
endif(CMAKE_SYSTEM MATCHES "Windows")
#add_library( PocoFoundation ${SRCS} )
#set_target_properties( PocoFoundation PROPERTIES COMPILE_FLAGS ${RELEASE_CPPFLAGS} )
#target_link_libraries( PocoFoundation pthread)
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} dl rt)
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} dl rt)
#add_subdirectory( testsuite )

121
Net/CMakeLists.txt Normal file
View File

@ -0,0 +1,121 @@
set(LIBNAME "PocoNet")
set(LIBNAMED "${LIBNAME}d")
set( BASE_SRCS
src/AbstractHTTPRequestHandler.cpp
src/DNS.cpp
src/DatagramSocket.cpp
src/DatagramSocketImpl.cpp
src/DialogSocket.cpp
src/FTPClientSession.cpp
src/FTPStreamFactory.cpp
src/FilePartSource.cpp
src/HTMLForm.cpp
src/HTTPBasicCredentials.cpp
src/HTTPBufferAllocator.cpp
src/HTTPChunkedStream.cpp
src/HTTPClientSession.cpp
src/HTTPCookie.cpp
src/HTTPFixedLengthStream.cpp
src/HTTPHeaderStream.cpp
src/HTTPIOStream.cpp
src/HTTPMessage.cpp
src/HTTPRequest.cpp
src/HTTPRequestHandler.cpp
src/HTTPRequestHandlerFactory.cpp
src/HTTPResponse.cpp
src/HTTPServer.cpp
src/HTTPServerConnection.cpp
src/HTTPServerConnectionFactory.cpp
src/HTTPServerParams.cpp
src/HTTPServerRequest.cpp
src/HTTPServerRequestImpl.cpp
src/HTTPServerResponse.cpp
src/HTTPServerResponseImpl.cpp
src/HTTPServerSession.cpp
src/HTTPSession.cpp
src/HTTPSessionFactory.cpp
src/HTTPSessionInstantiator.cpp
src/HTTPStream.cpp
src/HTTPStreamFactory.cpp
src/HostEntry.cpp
src/ICMPClient.cpp
src/ICMPEventArgs.cpp
src/ICMPPacket.cpp
src/ICMPPacketImpl.cpp
src/ICMPSocket.cpp
src/ICMPSocketImpl.cpp
src/ICMPv4PacketImpl.cpp
src/IPAddress.cpp
src/MailMessage.cpp
src/MailRecipient.cpp
src/MailStream.cpp
src/MediaType.cpp
src/MessageHeader.cpp
src/MulticastSocket.cpp
src/MultipartReader.cpp
src/MultipartWriter.cpp
src/NameValueCollection.cpp
src/NetException.cpp
src/NetworkInterface.cpp
src/NullPartHandler.cpp
src/POP3ClientSession.cpp
src/PartHandler.cpp
src/PartSource.cpp
src/QuotedPrintableDecoder.cpp
src/QuotedPrintableEncoder.cpp
src/RawSocket.cpp
src/RawSocketImpl.cpp
src/RemoteSyslogChannel.cpp
src/RemoteSyslogListener.cpp
src/SMTPClientSession.cpp
src/ServerSocket.cpp
src/ServerSocketImpl.cpp
src/Socket.cpp
src/SocketAddress.cpp
src/SocketImpl.cpp
src/SocketNotification.cpp
src/SocketNotifier.cpp
src/SocketReactor.cpp
src/SocketStream.cpp
src/StreamSocket.cpp
src/StreamSocketImpl.cpp
src/StringPartSource.cpp
src/TCPServer.cpp
src/TCPServerConnection.cpp
src/TCPServerConnectionFactory.cpp
src/TCPServerDispatcher.cpp
src/TCPServerParams.cpp
)
set( WIN_SRCS
)
set( LIN_SRCS
)
if(CMAKE_SYSTEM MATCHES "Windows")
set(SRCS ${BASE_SRCS} ${WIN_SRCS})
else (CMAKE_SYSTEM MATCHES "Windows")
set(SRCS ${BASE_SRCS} ${LIN_SRCS})
endif(CMAKE_SYSTEM MATCHES "Windows")
if (NOT POCO_STATIC)
add_definitions(-DNet_EXPORTS)
endif (NOT POCO_STATIC)
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} )
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} )
#add_subdirectory( testsuite )

57
Util/CMakeLists.txt Normal file
View File

@ -0,0 +1,57 @@
set(LIBNAME "PocoUtil")
set(LIBNAMED "${LIBNAME}d")
set( BASE_SRCS
src/AbstractConfiguration.cpp
src/Application.cpp
src/ConfigurationMapper.cpp
src/ConfigurationView.cpp
src/FilesystemConfiguration.cpp
src/HelpFormatter.cpp
src/IniFileConfiguration.cpp
src/IntValidator.cpp
src/LayeredConfiguration.cpp
src/LoggingConfigurator.cpp
src/LoggingSubsystem.cpp
src/MapConfiguration.cpp
src/Option.cpp
src/OptionCallback.cpp
src/OptionException.cpp
src/OptionProcessor.cpp
src/OptionSet.cpp
src/PropertyFileConfiguration.cpp
src/RegExpValidator.cpp
src/ServerApplication.cpp
src/Subsystem.cpp
src/SystemConfiguration.cpp
src/Validator.cpp
src/XMLConfiguration.cpp
)
set( WIN_SRCS
src/WinRegistryConfiguration.cpp
src/WinRegistryKey.cpp
src/WinService.cpp
)
if(CMAKE_SYSTEM MATCHES "Windows")
set(SRCS ${BASE_SRCS} ${WIN_SRCS})
else (CMAKE_SYSTEM MATCHES "Windows")
set(SRCS ${BASE_SRCS})
endif(CMAKE_SYSTEM MATCHES "Windows")
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} )
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} )
add_subdirectory( testsuite )

22
XML/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
set(LIBNAME "PocoXML")
set(LIBNAMED "${LIBNAME}d")
aux_source_directory(src SRCS)
add_definitions(-DXML_NS -DXML_DTD -DHAVE_EXPAT_CONFIG_H)
add_library( ${LIBNAME} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAME}
PROPERTIES COMPILE_FLAGS ${DEBUG_CXX_FLAGS}
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAME} )
add_library( ${LIBNAMED} ${LIB_MODE} ${SRCS} )
set_target_properties( ${LIBNAMED}
PROPERTIES COMPILE_FLAGS "${RELEASE_CXX_FLAGS}"
VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
target_link_libraries( ${LIBNAMED} )
#add_subdirectory( testsuite )

View File

@ -0,0 +1,57 @@
find_path(MYSQL_INCLUDE_DIR mysql.h
/usr/include/mysql
/usr/local/include/mysql
/opt/mysql/mysql/include
/opt/mysql/mysql/include/mysql
/usr/local/mysql/include
/usr/local/mysql/include/mysql
$ENV{MYSQL_INCLUDE_DIR}
$ENV{MYSQL_DIR}/include
$ENV{ProgramFiles}/MySQL/*/include
$ENV{SystemDrive}/MySQL/*/include)
if (WIN32)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(libsuffixDist debug)
set(libsuffixBuild Debug)
else (CMAKE_BUILD_TYPE STREQUAL Debug)
set(libsuffixDist opt)
set(libsuffixBuild Release)
add_definitions(-DDBUG_OFF)
endif (CMAKE_BUILD_TYPE STREQUAL Debug)
find_library(MYSQL_LIB NAMES mysqlclient
PATHS
$ENV{MYSQL_DIR}/lib/${libsuffixDist}
$ENV{MYSQL_DIR}/libmysql/${libsuffixBuild}
$ENV{MYSQL_DIR}/client/${libsuffixBuild}
$ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist}
$ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist})
else (WIN32)
find_library(MYSQL_LIB NAMES mysqlclient_r
PATHS
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/mysql/lib
/usr/local/mysql/lib/mysql
/opt/mysql/mysql/lib
/opt/mysql/mysql/lib/mysql
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql)
endif (WIN32)
if(MYSQL_LIB)
get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIB} PATH)
endif(MYSQL_LIB)
if (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
set(MYSQL_FOUND TRUE)
message(STATUS "MySQL Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
include_directories(${MYSQL_INCLUDE_DIR})
link_directories(${MYSQL_LIB_DIR})
else (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
message(FATAL_ERROR "Cannot find MySQL, include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
endif (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)

View File

@ -0,0 +1,32 @@
if(WITH_UNIXODBC)
# check for location of odbc_config
find_program(ODBC_CONFIG odbc_config $ENV{ODBC_PATH}/bin PATHS)
if(NOT ODBC_CONFIG)
message(FATAL_ERROR "Couldn't find unixODBC")
endif(NOT ODBC_CONFIG)
message(STATUS "unixODBC: Found odbc_config in ${ODBC_CONFIG}")
exec_program(${ODBC_CONFIG} ARGS "--include-prefix" OUTPUT_VARIABLE ODBC_INCLUDE_DIR)
set (CMAKE_FLAGS "${CMAKE_FLAGS} -I${ODBC_INCLUDE_DIR}")
exec_program(${ODBC_CONFIG} ARGS "--libs" OUTPUT_VARIABLE ODBC_LINK_FLAGS)
else(WITH_UNIXODBC)
find_program(ODBC_CONFIG iodbc-config $ENV{ODBC_PATH}/bin PATHS)
if(NOT ODBC_CONFIG)
message(FATAL_ERROR "Couldn't find iODBC")
endif(NOT ODBC_CONFIG)
message(STATUS "iODBC: Found iodbc-config in ${ODBC_CONFIG}")
exec_program(${ODBC_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE ODBC_CFLAGS)
set(CMAKE_FLAGS "${CMAKE_FLAGS} ${ODBC_CFLAGS}")
exec_program(${ODBC_CONFIG} ARGS "--libs" OUTPUT_VARIABLE ODBC_LINK_FLAGS)
endif(WITH_UNIXODBC)