From 4ed874500c66aeb60cb11a0acc081dbc113eec51 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 16 Jul 2010 09:58:26 +0200 Subject: Windows fixes and CMake scripts to build under Windows --- CMakeLists.txt | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 CMakeLists.txt (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..01cc4ce --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,112 @@ +cmake_minimum_required(VERSION 2.6.3) +project(librcc) + +set(CMAKE_VERBOSE_MAKEFILE YES) +set(CMAKE_BUILD_TYPE RELEASE) + +if (WIN32) + SET(USR_FOLDER "C:/DEVEL/UNIX" CACHE PATH "Path to libraries and includes") + SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${USR_FOLDER}/include) + INCLUDE_DIRECTORIES(${USR_FOLDER}/include) + + find_library(ZLIB_LIBRARY NAMES zlib PATHS ${USR_FOLDER} PATH_SUFFIXES "lib") + if (NOT ZLIB_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find zlib") + endif() + + find_library(LIBXML2_LIBRARY NAMES libxml2 PATHS ${USR_FOLDER} PATH_SUFFIXES "lib") + if (NOT LIBXML2_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find LibXML2") + endif() + + find_library(ICONV_LIBRARY NAMES libiconv PATHS ${USR_FOLDER} PATH_SUFFIXES "lib") + if (NOT ICONV_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find iconv") + endif () + + find_library(ENCA_LIBRARY NAMES libenca PATHS ${USR_FOLDER} PATH_SUFFIXES "lib") + if (ENCA_LIBRARY) + SET(HAVE_ENCA TRUE) + endif() + + find_library(LIBRCD_LIBRARY NAMES rcd PATHS ${USR_FOLDER} PATH_SUFFIXES "lib") + if (LIBRCD_LIBRARY) + SET(HAVE_RCD TRUE) + endif() + + find_library(WSOCK_LIBRARY NAMES wsock32) + if (NOT WSOCK_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find wsock library") + endif() + +else (WIN32) + MESSAGE(FATAL_ERROR "Windows build only, use autoconf for POSIX-compliant systems") +endif (WIN32) + + + +INCLUDE(CheckIncludeFiles) +CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H) +CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILES (sys/file.h HAVE_SYS_FILE_H) +CHECK_INCLUDE_FILES (sys/time.h HAVE_SYS_TIME_H) +CHECK_INCLUDE_FILES (sys/select.h HAVE_SYS_SELECT_H) +CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H) +CHECK_INCLUDE_FILES (sys/wait.h HAVE_SYS_WAIT_H) +CHECK_INCLUDE_FILES (signal.h HAVE_SIGNAL_H) +CHECK_INCLUDE_FILES (sys/un.h HAVE_SYS_UN_H) +CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H) +CHECK_INCLUDE_FILES (pwd.h HAVE_PWD_H) +CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H) +CHECK_INCLUDE_FILES (fcntl.h HAVE_FCNTL_H) +CHECK_INCLUDE_FILES (iconv.h HAVE_ICONV_H) +CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H) +CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) + +INCLUDE (CheckTypeSize) +CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T) +IF(NOT HAVE_SIZEOF_SIZE_T) + SET(size_t "unsigned int") +ENDIF(NOT HAVE_SIZEOF_SIZE_T) + +CHECK_TYPE_SIZE(ssize_t SIZEOF_SSIZE_T) +IF(NOT HAVE_SIZEOF_SSIZE_T) + CHECK_TYPE_SIZE("long" SIZEOF_LONG) + CHECK_TYPE_SIZE("__int64" SIZEOF___INT64) + IF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T) + SET(ssize_t long) + ENDIF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T) + IF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T) + SET(ssize_t __int64) + ENDIF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T) +ENDIF(NOT HAVE_SIZEOF_SSIZE_T) + +INCLUDE (CheckFunctionExists) +CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) +CHECK_FUNCTION_EXISTS(usleep HAVE_USLEEP) +CHECK_FUNCTION_EXISTS(flock HAVE_FLOCK) +CHECK_FUNCTION_EXISTS(lockf HAVE_LOCKF) +CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC) +CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP) +CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP) +CHECK_FUNCTION_EXISTS(ftruncate HAVE_FTRUNCATE) + +IF(NOT HAVE_STRCASECMP AND WIN32) + SET(strcasecmp _stricmp) +endif(NOT HAVE_STRCASECMP AND WIN32) + +IF(NOT HAVE_STRNCASECMP AND WIN32) + SET(strncasecmp _strnicmp) +endif(NOT HAVE_STRNCASECMP AND WIN32) + +IF(NOT HAVE_FTRUNCATE AND WIN32) + SET(ftruncate _chsize) +endif(NOT HAVE_FTRUNCATE AND WIN32) + +INCLUDE (CheckLibraryExists) +INCLUDE (CheckSymbolExists) + +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) + +add_subdirectory(src) +add_subdirectory(examples) -- cgit v1.2.3