From 2981eda00da91b7992d669a93d186efb9e28d48e Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Mon, 31 Mar 2014 01:49:17 +0200 Subject: Initial CMake configuration. Needs to be tested under OSX and Windows. --- CMakeLists.txt | 165 ++++++++++++++++++++++++++++++++++++++++++++ Tools/cmake/FindPCRE.cmake | 37 ++++++++++ Tools/cmake/swigconfig.h.in | 95 +++++++++++++++++++++++++ 3 files changed, 297 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 Tools/cmake/FindPCRE.cmake create mode 100644 Tools/cmake/swigconfig.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..fe2f0ccdc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,165 @@ +cmake_minimum_required (VERSION 3.2) + +if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") +endif () + +project (swig) + +file (STRINGS configure.ac line LIMIT_COUNT 1 REGEX "AC_INIT\\(.*\\)" ) +if (line MATCHES "AC_INIT\\(\\[(.*)\\],[ \t]*\\[(.*)\\],[ \t]*\\[(.*)\\]\\)" ) + set (SWIG_VERSION ${CMAKE_MATCH_2}) + set (PACKAGE_BUGREPORT ${CMAKE_MATCH_3}) +else () + message (SEND_ERROR "Could not parse version from configure.ac") +endif () + +set(SWIG_ROOT ${PROJECT_SOURCE_DIR}) + +set (SWIG_LIB share/swig/${SWIG_VERSION}) + +# Project wide configuration variables +# ------------------------------------ + +set(SWIG_SOURCE_DIR ${SWIG_ROOT}/Source CACHE INTERNAL "Path of swig sources" FORCE) + +set ( PACKAGE_NAME swig ) +set ( PACKAGE_VERSION ${SWIG_VERSION} ) + +# Options +# ------- + +# TODO... + + +# Configure +# --------- + +list (APPEND CMAKE_MODULE_PATH ${SWIG_ROOT}/Tools/cmake) + +include(CheckIncludeFiles) +include(CheckIncludeFile) +include(CheckTypeSize) +include(CheckSymbolExists) +include(CheckLibraryExists) +include(CheckCSourceCompiles) + +# HACK: didn't get the bool check working for Visual Studio 2008 +if(MSVC) +set(HAVE_BOOL 1) +else() +set(CMAKE_EXTRA_INCLUDE_FILES stdbool.h) +check_type_size("bool" HAVE_BOOL) +set(CMAKE_EXTRA_INCLUDE_FILES) +endif() + +check_include_file("inttypes.h" HAVE_INTTYPES_H) +check_include_file("memory.h" HAVE_MEMORY_H) +check_include_file("stddef.h" HAVE_STDDEF_H) +check_include_file("stdint.h" HAVE_STDINT_H) +check_include_file("stdlib.h" HAVE_STDLIB_H) +check_include_file("string.h" HAVE_STRING_H) +check_include_file("strings.h" HAVE_STRINGS_H) +check_include_file("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file("unistd.h" HAVE_UNISTD_H) +check_include_files( "stdlib.h;stdarg.h;string.h;float.h" HAVE_STDC_HEADERS ) + +check_library_exists(dl dlopen "" HAVE_LIBDL) + +find_package (PCRE REQUIRED) +if (PCRE_FOUND) + add_definitions (-DHAVE_PCRE) + include_directories (${PCRE_INCLUDE_DIRS}) +endif() + +configure_file (${SWIG_ROOT}/Tools/cmake/swigconfig.h.in + ${CMAKE_CURRENT_BINARY_DIR}/Source/Include/swigconfig.h) + +find_package (BISON REQUIRED) + + +# Compiler flags +# -------------- + +include_directories( + ${SWIG_SOURCE_DIR}/CParse + ${SWIG_SOURCE_DIR}/Include + ${SWIG_SOURCE_DIR}/DOH + ${SWIG_SOURCE_DIR}/Swig + ${SWIG_SOURCE_DIR}/Preprocessor + ${SWIG_SOURCE_DIR}/Modules + ${PROJECT_BINARY_DIR}/Source/Include + ${PROJECT_BINARY_DIR}/Source/CParse + ${PROJECT_SOURCE_DIR}/Source/Doxygen +) + +# generate the parser source code (depends on bison) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Source/CParse) + +BISON_TARGET(swig_parser + ${SWIG_SOURCE_DIR}/CParse/parser.y + ${PROJECT_BINARY_DIR}/Source/CParse/parser.c +) + +# generate swigwarn.swg +file(READ ${SWIG_SOURCE_DIR}/Include/swigwarn.h SWIG_WARN_H) +string(REGEX REPLACE "#define WARN([^ \\t]*)[ \\t]*([0-9]+)" "%define SWIGWARN\\1 \\2 %enddef" SWIG_WARN_SWG ${SWIG_WARN_H}) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg ${SWIG_WARN_SWG}) +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg PROPERTY GENERATED 1) + +# install lib +install (DIRECTORY ${SWIG_ROOT}/Lib/ DESTINATION ${SWIG_LIB}) +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg DESTINATION ${SWIG_LIB}) + +# Libraries +# --------- + +file (GLOB CPARSE_SOURCES ${SWIG_SOURCE_DIR}/CParse/*.c) +add_library (cparse ${CPARSE_SOURCES} + ${PROJECT_BINARY_DIR}/Source/CParse/parser.c + ${PROJECT_BINARY_DIR}/Source/CParse/parser.h +) + +file (GLOB PREPROCESSOR_SOURCES ${SWIG_SOURCE_DIR}/Preprocessor/*.c) +add_library (preprocessor ${PREPROCESSOR_SOURCES}) + +file (GLOB DOH_SOURCES ${SWIG_SOURCE_DIR}/DOH/*.c) +add_library (doh ${DOH_SOURCES}) + +file (GLOB DOXYGEN_SOURCES ${SWIG_SOURCE_DIR}/Doxygen/*.cxx) +add_library (doxygen ${DOXYGEN_SOURCES}) + +file (GLOB CORE_SOURCES ${SWIG_SOURCE_DIR}/Swig/*.c) +add_library (core ${CORE_SOURCES}) +if (PCRE_FOUND) + target_link_libraries (core ${PCRE_LIBRARIES}) +endif () + +file (GLOB MODULES_SOURCES ${SWIG_SOURCE_DIR}/Modules/*.cxx) +add_library (modules ${MODULES_SOURCES} + ${PROJECT_BINARY_DIR}/Source/Include/swigconfig.h + ${SWIG_SOURCE_DIR}/Include/swigwarn.h +) +target_link_libraries(modules doxygen) + +add_executable(swig + ${SWIG_SOURCE_DIR}/Modules/main.cxx + ${SWIG_SOURCE_DIR}/Modules/swigmain.cxx +) + +target_link_libraries (swig cparse preprocessor doh core modules) +install (TARGETS swig DESTINATION bin) + + +# 'make package-source' creates tarballs +set ( CPACK_PACKAGE_NAME ${PACKAGE_NAME} ) +set ( CPACK_SOURCE_GENERATOR "TGZ;TBZ2" ) +set ( CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}" ) +set ( CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION} ) +include ( CPack ) + +enable_testing() +add_test (NAME cmd_version COMMAND swig -version) +add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) +set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") diff --git a/Tools/cmake/FindPCRE.cmake b/Tools/cmake/FindPCRE.cmake new file mode 100644 index 000000000..dbbd60ada --- /dev/null +++ b/Tools/cmake/FindPCRE.cmake @@ -0,0 +1,37 @@ +# Copyright (C) 2007-2009 LuaDist. +# Created by Peter Kapec +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Note: +# Searching headers and libraries is very simple and is NOT as powerful as scripts +# distributed with CMake, because LuaDist defines directories to search for. +# Everyone is encouraged to contact the author with improvements. Maybe this file +# becomes part of CMake distribution sometimes. + +# - Find pcre +# Find the native PCRE headers and libraries. +# +# PCRE_INCLUDE_DIRS - where to find pcre.h, etc. +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + +# Look for the header file. +FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h) + +# Look for the library. +FIND_LIBRARY(PCRE_LIBRARY NAMES pcre) + +# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR) + +# Copy the results to the output variables. +IF(PCRE_FOUND) + SET(PCRE_LIBRARIES ${PCRE_LIBRARY}) + SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) +ELSE(PCRE_FOUND) + SET(PCRE_LIBRARIES) + SET(PCRE_INCLUDE_DIRS) +ENDIF(PCRE_FOUND) + +MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES) diff --git a/Tools/cmake/swigconfig.h.in b/Tools/cmake/swigconfig.h.in new file mode 100644 index 000000000..3f72818f0 --- /dev/null +++ b/Tools/cmake/swigconfig.h.in @@ -0,0 +1,95 @@ +/* Tools/cmake/swigconfig.h.in Generated by cmake. */ + +/* define if the Boost library is available */ +#cmakedefine HAVE_BOOST + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#cmakedefine HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +#cmakedefine HAVE_LIBDLD 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define if pcre is available */ +#cmakedefine HAVE_PCRE 1 + +/* Define if popen is available */ +#cmakedefine HAVE_POPEN 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Name of package */ +#define PACKAGE "swig" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "http://www.swig.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "swig" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "swig @SWIG_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "swig" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://www.swig.org" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@SWIG_VERSION@" + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Compiler that built SWIG */ +#define SWIG_CXX "@SWIG_CXX@" + +/* Directory for SWIG system-independent libraries */ +#define SWIG_LIB "@CMAKE_INSTALL_PREFIX@/@SWIG_LIB@" + +/* Directory for SWIG system-independent libraries (Unix install on native + Windows) */ +#define SWIG_LIB_WIN_UNIX "C:/cygwin/usr/local/@SWIG_LIB@" + +/* Platform that SWIG is built for */ +#define SWIG_PLATFORM "i686-pc-cygwin" + +/* Version number of package */ +#define VERSION "@SWIG_VERSION@" + +/* Default language */ +#define SWIG_LANG "-tcl" + +/* Deal with attempt by Microsoft to deprecate C standard runtime functions */ +#if defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + -- cgit v1.2.1 From 72aefd2207b677a794f8129eeaeca944ce204487 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Thu, 12 Oct 2017 17:23:07 +0200 Subject: Enable cmake build in CI --- .travis.yml | 15 +++++++++++++++ appveyor.yml | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6572bb74b..e8b65d0d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,18 @@ matrix: os: linux env: SWIGLANG= dist: xenial + - compiler: clang + os: linux + env: SWIGLANG= BUILDSYSTEM=cmake + dist: xenial - compiler: gcc os: linux env: SWIGLANG= dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG= BUILDSYSTEM=cmake + dist: xenial - os: linux env: SWIGLANG= GCC=4.4 dist: xenial @@ -342,6 +350,12 @@ matrix: os: osx osx_image: xcode12.2 env: SWIGLANG= + - compiler: gcc + os: osx + env: SWIGLANG= BUILDSYSTEM=cmake + - compiler: clang + os: osx + env: SWIGLANG= BUILDSYSTEM=cmake - compiler: clang os: osx osx_image: xcode12.2 @@ -439,6 +453,7 @@ install: - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi - ls -la $(which $CC) $(which $CXX) && $CC --version && $CXX --version script: + - if test "$BUILDSYSTEM" = "cmake"; then mkdir -p build/build && cd build/build && cmake -DCMAKE_INSTALL_PREFIX=~/.local ../.. && make install && ctest --output-on-failure -V && exit 0; fi - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi diff --git a/appveyor.yml b/appveyor.yml index 3dc08a0de..cf84dd1ea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,6 +30,8 @@ environment: # WITHLANG: python # VER: 37 # PY3: 3 + - BUILDSYSTEM: cmake + VSVER: 14 matrix: allow_failures: @@ -51,6 +53,7 @@ install: $env:MINGWBIN="C:\msys64\mingw32\bin" $env:MBITS="32" $env:MARCH="i686" + $env:VSARCH="" } else { $env:PCRE_PLATFORM="x64" $env:JAVA_HOME="C:/Program Files/Java/jdk1.8.0" @@ -62,6 +65,7 @@ install: $env:MINGWBIN="C:\msys64\mingw64\bin" $env:MBITS="64" $env:MARCH="x86_64" + $env:VSARCH=" Win64" } - ps: >- if (!$env:OSVARIANT) { @@ -114,6 +118,7 @@ build_script: - set CCCL_OPTIONS=--cccl-muffle /W3 /EHsc - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor +- if "%BUILDSYSTEM%"=="cmake" cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit - if "%OSVARIANT%"=="" bash -c "exec 0 Date: Mon, 22 Feb 2021 09:24:15 +0100 Subject: Misc fixes --- CMakeLists.txt | 159 +++++++++++++++++++++----------------------- Tools/cmake/swigconfig.h.in | 28 ++++---- appveyor.yml | 2 +- 3 files changed, 92 insertions(+), 97 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe2f0ccdc..fbe8023dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ endif () project (swig) +if (POLICY CMP0074) + cmake_policy (SET CMP0074 NEW) +endif() + file (STRINGS configure.ac line LIMIT_COUNT 1 REGEX "AC_INIT\\(.*\\)" ) if (line MATCHES "AC_INIT\\(\\[(.*)\\],[ \t]*\\[(.*)\\],[ \t]*\\[(.*)\\]\\)" ) set (SWIG_VERSION ${CMAKE_MATCH_2}) @@ -14,65 +18,67 @@ else () message (SEND_ERROR "Could not parse version from configure.ac") endif () -set(SWIG_ROOT ${PROJECT_SOURCE_DIR}) +set (SWIG_ROOT ${PROJECT_SOURCE_DIR}) set (SWIG_LIB share/swig/${SWIG_VERSION}) # Project wide configuration variables # ------------------------------------ -set(SWIG_SOURCE_DIR ${SWIG_ROOT}/Source CACHE INTERNAL "Path of swig sources" FORCE) - -set ( PACKAGE_NAME swig ) -set ( PACKAGE_VERSION ${SWIG_VERSION} ) - -# Options -# ------- - -# TODO... +set (SWIG_SOURCE_DIR ${SWIG_ROOT}/Source CACHE INTERNAL "Path of swig sources" FORCE) +set (PACKAGE_NAME swig) +set (PACKAGE_VERSION ${SWIG_VERSION}) # Configure # --------- list (APPEND CMAKE_MODULE_PATH ${SWIG_ROOT}/Tools/cmake) -include(CheckIncludeFiles) -include(CheckIncludeFile) -include(CheckTypeSize) -include(CheckSymbolExists) -include(CheckLibraryExists) -include(CheckCSourceCompiles) +include (CheckIncludeFiles) +include (CheckIncludeFile) +include (CheckIncludeFileCXX) +include (CheckTypeSize) +include (CheckSymbolExists) +include (CheckFunctionExists) +include (CheckLibraryExists) +include (CheckCSourceCompiles) # HACK: didn't get the bool check working for Visual Studio 2008 -if(MSVC) -set(HAVE_BOOL 1) +if (MSVC) + set(HAVE_BOOL 1) else() -set(CMAKE_EXTRA_INCLUDE_FILES stdbool.h) -check_type_size("bool" HAVE_BOOL) -set(CMAKE_EXTRA_INCLUDE_FILES) + set (CMAKE_EXTRA_INCLUDE_FILES stdbool.h) + check_type_size ("bool" HAVE_BOOL) + set (CMAKE_EXTRA_INCLUDE_FILES) endif() -check_include_file("inttypes.h" HAVE_INTTYPES_H) -check_include_file("memory.h" HAVE_MEMORY_H) -check_include_file("stddef.h" HAVE_STDDEF_H) -check_include_file("stdint.h" HAVE_STDINT_H) -check_include_file("stdlib.h" HAVE_STDLIB_H) -check_include_file("string.h" HAVE_STRING_H) -check_include_file("strings.h" HAVE_STRINGS_H) -check_include_file("sys/stat.h" HAVE_SYS_STAT_H) -check_include_file("sys/types.h" HAVE_SYS_TYPES_H) -check_include_file("unistd.h" HAVE_UNISTD_H) -check_include_files( "stdlib.h;stdarg.h;string.h;float.h" HAVE_STDC_HEADERS ) - -check_library_exists(dl dlopen "" HAVE_LIBDL) - -find_package (PCRE REQUIRED) +check_include_file ("inttypes.h" HAVE_INTTYPES_H) +check_include_file ("stddef.h" HAVE_STDDEF_H) +check_include_file ("stdint.h" HAVE_STDINT_H) +check_include_file ("stdio.h" HAVE_STDIO_H) +check_include_file ("stdlib.h" HAVE_STDLIB_H) +check_include_file ("string.h" HAVE_STRING_H) +check_include_file ("strings.h" HAVE_STRINGS_H) +check_include_file ("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file ("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file ("unistd.h" HAVE_UNISTD_H) +check_include_files ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) + +check_include_file_cxx ("boost/shared_ptr.hpp" HAVE_BOOST) +check_library_exists (dl dlopen "" HAVE_LIBDL) +check_function_exists (popen HAVE_POPEN) + +set (PCRE_REQUIRED_ARG "REQUIRED" CACHE STRING "required arg") +find_package (PCRE ${PCRE_REQUIRED_ARG}) if (PCRE_FOUND) - add_definitions (-DHAVE_PCRE) + set (HAVE_PCRE 1) include_directories (${PCRE_INCLUDE_DIRS}) endif() +if (WIN32) + file (TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${SWIG_LIB} SWIG_LIB_WIN_UNIX) +endif () configure_file (${SWIG_ROOT}/Tools/cmake/swigconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/Source/Include/swigconfig.h) @@ -82,7 +88,7 @@ find_package (BISON REQUIRED) # Compiler flags # -------------- -include_directories( +include_directories ( ${SWIG_SOURCE_DIR}/CParse ${SWIG_SOURCE_DIR}/Include ${SWIG_SOURCE_DIR}/DOH @@ -95,71 +101,60 @@ include_directories( ) # generate the parser source code (depends on bison) -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Source/CParse) +file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Source/CParse) -BISON_TARGET(swig_parser +BISON_TARGET (swig_parser ${SWIG_SOURCE_DIR}/CParse/parser.y ${PROJECT_BINARY_DIR}/Source/CParse/parser.c ) # generate swigwarn.swg -file(READ ${SWIG_SOURCE_DIR}/Include/swigwarn.h SWIG_WARN_H) -string(REGEX REPLACE "#define WARN([^ \\t]*)[ \\t]*([0-9]+)" "%define SWIGWARN\\1 \\2 %enddef" SWIG_WARN_SWG ${SWIG_WARN_H}) -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg ${SWIG_WARN_SWG}) -set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg PROPERTY GENERATED 1) +file (READ ${SWIG_SOURCE_DIR}/Include/swigwarn.h SWIG_WARN_H) +string (REGEX REPLACE "#define WARN([^ \\t]*)[ \\t]*([0-9]+)" "%define SWIGWARN\\1 \\2 %enddef" SWIG_WARN_SWG ${SWIG_WARN_H}) +file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg ${SWIG_WARN_SWG}) +set_property (SOURCE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg PROPERTY GENERATED 1) # install lib install (DIRECTORY ${SWIG_ROOT}/Lib/ DESTINATION ${SWIG_LIB}) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg DESTINATION ${SWIG_LIB}) -# Libraries +# sources # --------- - +file (GLOB DOH_SOURCES ${SWIG_SOURCE_DIR}/DOH/*.c) file (GLOB CPARSE_SOURCES ${SWIG_SOURCE_DIR}/CParse/*.c) -add_library (cparse ${CPARSE_SOURCES} - ${PROJECT_BINARY_DIR}/Source/CParse/parser.c - ${PROJECT_BINARY_DIR}/Source/CParse/parser.h -) - +list (APPEND CPARSE_SOURCES) file (GLOB PREPROCESSOR_SOURCES ${SWIG_SOURCE_DIR}/Preprocessor/*.c) -add_library (preprocessor ${PREPROCESSOR_SOURCES}) - -file (GLOB DOH_SOURCES ${SWIG_SOURCE_DIR}/DOH/*.c) -add_library (doh ${DOH_SOURCES}) - -file (GLOB DOXYGEN_SOURCES ${SWIG_SOURCE_DIR}/Doxygen/*.cxx) -add_library (doxygen ${DOXYGEN_SOURCES}) - file (GLOB CORE_SOURCES ${SWIG_SOURCE_DIR}/Swig/*.c) -add_library (core ${CORE_SOURCES}) -if (PCRE_FOUND) - target_link_libraries (core ${PCRE_LIBRARIES}) -endif () - +file (GLOB DOXYGEN_SOURCES ${SWIG_SOURCE_DIR}/Doxygen/*.cxx) file (GLOB MODULES_SOURCES ${SWIG_SOURCE_DIR}/Modules/*.cxx) -add_library (modules ${MODULES_SOURCES} - ${PROJECT_BINARY_DIR}/Source/Include/swigconfig.h - ${SWIG_SOURCE_DIR}/Include/swigwarn.h -) -target_link_libraries(modules doxygen) -add_executable(swig - ${SWIG_SOURCE_DIR}/Modules/main.cxx - ${SWIG_SOURCE_DIR}/Modules/swigmain.cxx +add_executable (swig + ${CPARSE_SOURCES} + ${DOH_SOURCES} + ${DOXYGEN_SOURCES} + ${MODULES_SOURCES} + ${CORE_SOURCES} + ${PREPROCESSOR_SOURCES} + ${PROJECT_BINARY_DIR}/Source/Include/swigconfig.h + ${SWIG_SOURCE_DIR}/Include/swigwarn.h + ${PROJECT_BINARY_DIR}/Source/CParse/parser.c + ${PROJECT_BINARY_DIR}/Source/CParse/parser.h ) - -target_link_libraries (swig cparse preprocessor doh core modules) +if (PCRE_FOUND) + target_link_libraries (swig ${PCRE_LIBRARIES}) +endif () install (TARGETS swig DESTINATION bin) - # 'make package-source' creates tarballs -set ( CPACK_PACKAGE_NAME ${PACKAGE_NAME} ) -set ( CPACK_SOURCE_GENERATOR "TGZ;TBZ2" ) -set ( CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}" ) -set ( CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION} ) -include ( CPack ) - -enable_testing() +set (CPACK_PACKAGE_NAME ${PACKAGE_NAME}) +set (CPACK_SOURCE_GENERATOR "TGZ;TBZ2") +set (CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}") +set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION}) +include (CPack) + +# few tests +enable_testing () add_test (NAME cmd_version COMMAND swig -version) add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") + diff --git a/Tools/cmake/swigconfig.h.in b/Tools/cmake/swigconfig.h.in index 3f72818f0..94cee1646 100644 --- a/Tools/cmake/swigconfig.h.in +++ b/Tools/cmake/swigconfig.h.in @@ -1,7 +1,7 @@ -/* Tools/cmake/swigconfig.h.in Generated by cmake. */ +/* swigconfig.h. Generated by cmake from Tools/cmake/swigconfig.h.in */ /* define if the Boost library is available */ -#cmakedefine HAVE_BOOST +#cmakedefine HAVE_BOOST 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 @@ -12,10 +12,7 @@ /* Define to 1 if you have the `dld' library (-ldld). */ #cmakedefine HAVE_LIBDLD 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H 1 - -/* Define if pcre is available */ +/* Define if you have PCRE library */ #cmakedefine HAVE_PCRE 1 /* Define if popen is available */ @@ -24,6 +21,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDIO_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDLIB_H 1 @@ -58,35 +58,35 @@ #define PACKAGE_TARNAME "swig" /* Define to the home page for this package. */ -#define PACKAGE_URL "http://www.swig.org" +#define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "@SWIG_VERSION@" /* The size of `void *', as computed by sizeof. */ -#define SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@ +/* #undef SIZEOF_VOID_P */ -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #cmakedefine STDC_HEADERS 1 /* Compiler that built SWIG */ -#define SWIG_CXX "@SWIG_CXX@" +#define SWIG_CXX "@CMAKE_CXX_COMPILER@" /* Directory for SWIG system-independent libraries */ #define SWIG_LIB "@CMAKE_INSTALL_PREFIX@/@SWIG_LIB@" /* Directory for SWIG system-independent libraries (Unix install on native Windows) */ -#define SWIG_LIB_WIN_UNIX "C:/cygwin/usr/local/@SWIG_LIB@" +#define SWIG_LIB_WIN_UNIX "@SWIG_LIB_WIN_UNIX@" /* Platform that SWIG is built for */ -#define SWIG_PLATFORM "i686-pc-cygwin" +#define SWIG_PLATFORM "@CMAKE_SYSTEM_NAME@" /* Version number of package */ #define VERSION "@SWIG_VERSION@" -/* Default language */ -#define SWIG_LANG "-tcl" /* Deal with attempt by Microsoft to deprecate C standard runtime functions */ #if defined(_MSC_VER) diff --git a/appveyor.yml b/appveyor.yml index cf84dd1ea..47cf893bb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -118,7 +118,7 @@ build_script: - set CCCL_OPTIONS=--cccl-muffle /W3 /EHsc - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor -- if "%BUILDSYSTEM%"=="cmake" cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit +- if "%BUILDSYSTEM%"=="cmake" cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DCMAKE_CXX_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit - if "%OSVARIANT%"=="" bash -c "exec 0 Date: Mon, 1 Mar 2021 23:42:52 +0000 Subject: CMake test, run -swiglib --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbe8023dd..b36f441fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,7 @@ include (CPack) # few tests enable_testing () add_test (NAME cmd_version COMMAND swig -version) +add_test (NAME cmd_swiglib COMMAND swig -swiglib) add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") -- cgit v1.2.1