summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMichel Zou <xantares09@hotmail.com>2021-02-22 09:24:15 +0100
committerMichel Zou <xantares09@hotmail.com>2021-02-26 17:07:59 +0100
commit3d049f6b2a341f217aa9d5aa8cde02ad581a37d6 (patch)
tree55b705abd4245c75c54cb03645b92b50820a14fe /CMakeLists.txt
parent72aefd2207b677a794f8129eeaeca944ce204487 (diff)
downloadswig-3d049f6b2a341f217aa9d5aa8cde02ad581a37d6.tar.gz
Misc fixes
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt159
1 files changed, 77 insertions, 82 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")
+