2017-10-02 16:17:16 +00:00
|
|
|
##############################################################################
|
|
|
|
# @file CMakeLists.txt
|
|
|
|
# Build executables, static and dylibs, packages, build systems, etc., for
|
|
|
|
# HTML Tidy.
|
|
|
|
#
|
|
|
|
# Read this file or use cmake-gui (Windows) or ccmake (everything else) for
|
|
|
|
# guided build.
|
|
|
|
#
|
|
|
|
# @author Geoff McLane [ubuntu@geoffair.info]
|
|
|
|
# @author HTACG, et al (consult git log)
|
|
|
|
#
|
|
|
|
# @copyright
|
|
|
|
# Copyright (c) 1998-2017 HTACG
|
|
|
|
# @copyright
|
|
|
|
# See tidy.h for license.
|
|
|
|
#
|
|
|
|
# @date Consult git log.
|
|
|
|
##############################################################################
|
|
|
|
|
2017-10-03 12:57:11 +00:00
|
|
|
cmake_minimum_required (VERSION 2.8.12)
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2015-06-30 17:59:00 +00:00
|
|
|
set(LIB_NAME tidy)
|
2017-04-17 22:21:07 +00:00
|
|
|
set(LIBTIDY_DESCRIPTION "${LIB_NAME} - HTML syntax checker")
|
|
|
|
set(LIBTIDY_URL "http://www.html-tidy.org")
|
2015-04-02 11:17:14 +00:00
|
|
|
|
|
|
|
project (${LIB_NAME})
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#################################################
|
|
|
|
# Setup
|
|
|
|
#################################################
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Release Information
|
|
|
|
# Release version and date are found in `version.txt`; update *that*
|
|
|
|
# file when required. It will be read into variable `versionFile`
|
|
|
|
# (stripping any newlines or spaces). This file must be formatted into
|
|
|
|
# two lines: the dot-separated MAJOR.MINOR.POINT version, followed by
|
|
|
|
# the date separated YEAR.MONTH.DAY release date.
|
|
|
|
#------------------------------------------------------------------------
|
2015-01-29 17:25:57 +00:00
|
|
|
file(READ version.txt versionFile)
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2015-01-29 17:25:57 +00:00
|
|
|
if (NOT versionFile)
|
|
|
|
message(FATAL_ERROR "Unable to determine libtidy version. version.txt file is missing.")
|
|
|
|
endif()
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2015-06-09 10:17:43 +00:00
|
|
|
string(STRIP "${versionFile}" VERSION_TEXT)
|
|
|
|
string(REGEX REPLACE "(.*)[\r\n|\n](.*)" "\\1" LIBTIDY_VERSION ${VERSION_TEXT})
|
|
|
|
string(REGEX REPLACE "(.*)[\r\n|\n](.*)" "\\2" LIBTIDY_DATE ${VERSION_TEXT})
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
# Establish version number
|
2015-06-09 10:17:43 +00:00
|
|
|
if (LIBTIDY_VERSION)
|
|
|
|
string(REPLACE "." ";" VERSION_LIST ${LIBTIDY_VERSION})
|
|
|
|
list(GET VERSION_LIST 0 TIDY_MAJOR_VERSION)
|
|
|
|
list(GET VERSION_LIST 1 TIDY_MINOR_VERSION)
|
|
|
|
list(GET VERSION_LIST 2 TIDY_POINT_VERSION)
|
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "*** FAILED to get a VERSION from version.txt!")
|
2017-10-02 16:17:16 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Establish version date
|
2015-06-09 10:17:43 +00:00
|
|
|
if (LIBTIDY_DATE)
|
|
|
|
string(REPLACE "." ";" DATE_LIST ${LIBTIDY_DATE})
|
|
|
|
list(GET DATE_LIST 0 tidy_YEAR)
|
|
|
|
list(GET DATE_LIST 1 tidy_MONTH)
|
|
|
|
list(GET DATE_LIST 2 tidy_DAY)
|
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "*** FAILED to get a DATE from version.txt!")
|
|
|
|
endif ()
|
2015-01-27 18:11:01 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Library Types and Linking
|
|
|
|
# By default, *both* static and dynamic library types are built. The
|
|
|
|
# shared library can be turned off if not needed. The console program
|
|
|
|
# can be configured for static linking or dynamic linking.
|
|
|
|
#------------------------------------------------------------------------
|
2015-12-04 17:31:24 +00:00
|
|
|
set( LIB_TYPE STATIC ) # set default message
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
option( BUILD_SHARED_LIB "Set OFF to NOT build shared library" ON )
|
|
|
|
|
2015-12-04 17:31:24 +00:00
|
|
|
# Issue #326 - Allow linkage choice of console app tidy
|
|
|
|
option( TIDY_CONSOLE_SHARED "Set ON to link with shared(DLL) lib." OFF )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2015-12-04 17:31:24 +00:00
|
|
|
if (TIDY_CONSOLE_SHARED)
|
|
|
|
if (NOT BUILD_SHARED_LIB)
|
|
|
|
message(FATAL_ERROR "Enable shared build for this tidy linkage!")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Miscellaneous Options
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
option( BUILD_TAB2SPACE "Set ON to build utility app, tab2space" OFF )
|
|
|
|
option( BUILD_SAMPLE_CODE "Set ON to build the sample code" OFF )
|
|
|
|
option( TIDY_COMPAT_HEADERS "Set ON to include compatibility headers" OFF )
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Man Page
|
|
|
|
# Allow building with non-default man page directory.
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
if (NOT MAN_INSTALL_DIR)
|
|
|
|
set(MAN_INSTALL_DIR share/man/man1)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Localization
|
|
|
|
# Allow building without extra language support.
|
|
|
|
#------------------------------------------------------------------------
|
2016-01-15 04:06:15 +00:00
|
|
|
option( SUPPORT_LOCALIZATIONS "Set OFF to build without additional languages." ON )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2016-01-15 04:06:15 +00:00
|
|
|
if (SUPPORT_LOCALIZATIONS)
|
2017-10-02 16:17:16 +00:00
|
|
|
add_definitions ( -DSUPPORT_LOCALIZATIONS=1 )
|
2016-01-15 04:06:15 +00:00
|
|
|
else ()
|
2017-10-02 16:17:16 +00:00
|
|
|
add_definitions ( -DSUPPORT_LOCALIZATIONS=0 )
|
2016-01-15 04:06:15 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Console Application
|
|
|
|
# Allow building without console support, which mostly prevents
|
|
|
|
# console strings from existing in the library. Note that this will
|
|
|
|
# prevent the console application from being built, since it can't be
|
|
|
|
# linked.
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
option( SUPPORT_CONSOLE_APP "Set OFF to build libraries only without console application support." ON )
|
|
|
|
|
2017-02-13 19:29:47 +00:00
|
|
|
if (SUPPORT_CONSOLE_APP)
|
2017-10-02 16:17:16 +00:00
|
|
|
add_definitions ( -DSUPPORT_CONSOLE_APP=1 )
|
2017-02-13 19:29:47 +00:00
|
|
|
else ()
|
2017-10-02 16:17:16 +00:00
|
|
|
add_definitions ( -DSUPPORT_CONSOLE_APP=0 )
|
2017-02-13 19:29:47 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
2017-10-07 18:07:12 +00:00
|
|
|
# Diagnostics
|
|
|
|
# Enable building with logs, some memory diagnostics.
|
2017-10-02 16:17:16 +00:00
|
|
|
#------------------------------------------------------------------------
|
2017-10-08 23:25:42 +00:00
|
|
|
option( ENABLE_DEBUG_LOG "Set ON to output debugging messages." OFF )
|
2017-10-08 15:06:41 +00:00
|
|
|
option( ENABLE_ALLOC_DEBUG "Set ON to output node allocation diagnostics." OFF )
|
|
|
|
option( ENABLE_MEMORY_DEBUG "Set ON to output some memory diagnostics." OFF )
|
2017-10-07 18:07:12 +00:00
|
|
|
|
|
|
|
if ( ENABLE_DEBUG_LOG )
|
2017-10-07 18:56:01 +00:00
|
|
|
add_definitions( -DENABLE_DEBUG_LOG )
|
2017-10-07 18:07:12 +00:00
|
|
|
message(STATUS "*** Debug Logging is enabled.")
|
|
|
|
else ()
|
|
|
|
message(STATUS "*** Debug Logging is NOT enabled.")
|
|
|
|
endif ()
|
|
|
|
|
2017-10-04 02:31:55 +00:00
|
|
|
if (ENABLE_ALLOC_DEBUG)
|
|
|
|
add_definitions ( -DDEBUG_ALLOCATION ) # see lexer.c for details
|
|
|
|
message(STATUS "*** Note, lexer.c node allocation diagnostics are ON")
|
|
|
|
endif ()
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2017-10-07 18:56:01 +00:00
|
|
|
if (ENABLE_MEMORY_DEBUG)
|
|
|
|
add_definitions ( -DDEBUG_MEMORY ) # see alloc.c for details
|
|
|
|
message(STATUS "*** Note, alloc.c memory diagnostics are ON")
|
|
|
|
endif ()
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2017-10-04 02:31:55 +00:00
|
|
|
if (WIN32)
|
|
|
|
option( ENABLE_CRTDBG_MEMORY "Set ON to enable the Windows CRT debug library." OFF )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2017-09-17 14:25:05 +00:00
|
|
|
if (ENABLE_CRTDBG_MEMORY)
|
|
|
|
add_definitions ( -D_CRTDBG_MAP_ALLOC ) # see tidy.c for details
|
|
|
|
message(STATUS "*** Note, tidy.c Windows CRT memory debug is ON")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Complier Flags
|
|
|
|
# Setup other compiler-specific and platform-specific compiler flags.
|
|
|
|
#------------------------------------------------------------------------
|
2014-08-03 18:08:57 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set( WARNING_FLAGS -Wall )
|
|
|
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set( WARNING_FLAGS "-Wall -Wno-overloaded-virtual" )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32 AND MSVC)
|
2017-10-02 16:17:16 +00:00
|
|
|
# C4996: The compiler encountered a deprecated declaration.
|
2014-08-03 18:08:57 +00:00
|
|
|
# C4090: 'function' : different 'const' qualifiers
|
2014-08-06 10:09:13 +00:00
|
|
|
# C4244: '=' : conversion from '__int64' to 'uint', possible loss of data
|
|
|
|
# C4267: 'function' : conversion from 'size_t' to 'uint', possible loss of data
|
2017-10-02 16:17:16 +00:00
|
|
|
foreach(warning 4996 4090 4244 4267)
|
2014-08-03 18:08:57 +00:00
|
|
|
set(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
|
|
|
|
endforeach()
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2014-08-03 18:08:57 +00:00
|
|
|
set( MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS" )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2015-01-20 17:09:01 +00:00
|
|
|
# to distinguish between debug and release lib in windows
|
|
|
|
set( CMAKE_DEBUG_POSTFIX "d" ) # little effect in unix
|
2014-08-03 18:08:57 +00:00
|
|
|
else()
|
2014-08-06 10:09:13 +00:00
|
|
|
# add any gcc flags
|
2014-08-03 18:08:57 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT" )
|
|
|
|
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT" )
|
|
|
|
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}" )
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Static Windows Runtime
|
|
|
|
# Option to statically link to the Windows runtime. Maybe only
|
|
|
|
# applies to WIN32/MSVC.
|
|
|
|
#------------------------------------------------------------------------
|
2017-03-23 13:53:44 +00:00
|
|
|
if (MSVC)
|
|
|
|
option( USE_STATIC_RUNTIME "Set ON to change /MD(DLL) to /MT(static)" OFF )
|
|
|
|
if (USE_STATIC_RUNTIME)
|
|
|
|
set(CompilerFlags
|
|
|
|
CMAKE_CXX_FLAGS
|
|
|
|
CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_C_FLAGS
|
|
|
|
CMAKE_C_FLAGS_DEBUG
|
|
|
|
CMAKE_C_FLAGS_RELEASE
|
|
|
|
)
|
|
|
|
foreach(CompilerFlag ${CompilerFlags})
|
|
|
|
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
|
|
|
endforeach()
|
|
|
|
message(STATUS "Using /MT STATIC runtime")
|
|
|
|
else ()
|
|
|
|
message(STATUS "Using /MD DYNAMIC runtime")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Macro Values
|
2017-10-03 17:56:31 +00:00
|
|
|
# These additional macros are set in Tidy's source code. It is *very*
|
|
|
|
# seldom that you would ever have to change any of these in order to
|
|
|
|
# achieve a functioning build.
|
2017-10-02 16:17:16 +00:00
|
|
|
#------------------------------------------------------------------------
|
2015-01-29 17:25:57 +00:00
|
|
|
add_definitions ( -DLIBTIDY_VERSION="${LIBTIDY_VERSION}" )
|
2015-06-09 10:17:43 +00:00
|
|
|
add_definitions ( -DRELEASE_DATE="${tidy_YEAR}/${tidy_MONTH}/${tidy_DAY}" )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
# Optionally specify an extra version point for pre-release/debug versions.
|
2017-03-15 18:57:47 +00:00
|
|
|
if (TIDY_RC_NUMBER)
|
|
|
|
add_definitions ( -DRC_NUMBER="${TIDY_RC_NUMBER}" )
|
|
|
|
endif ()
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2017-10-03 17:04:37 +00:00
|
|
|
# If your OS doesn't have native ISO2022 support, then build with this flag.
|
|
|
|
if (NO_NATIVE_ISO2022_SUPPORT)
|
|
|
|
add_definitions ( -DNO_NATIVE_ISO2022_SUPPORT=1 )
|
|
|
|
endif ()
|
|
|
|
|
2017-10-03 17:56:31 +00:00
|
|
|
# If your OS doesn't have library function access(), build with this flag.
|
|
|
|
if (NO_ACCESS_SUPPORT)
|
|
|
|
add_definitions ( -DNO_ACCESS_SUPPORT=1 )
|
|
|
|
endif ()
|
2017-10-03 17:04:37 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
# Delete me? Not used in Tidy source!
|
|
|
|
add_definitions ( -DHAVE_CONFIG_H )
|
2017-09-30 21:06:19 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
2017-10-02 14:42:25 +00:00
|
|
|
# Runtime Configuration File Support
|
2017-09-30 21:06:19 +00:00
|
|
|
# By default on Unix-like systems when building for the console program,
|
|
|
|
# support runtime configuration files in /etc/ and in ~/. To prevent this,
|
|
|
|
# set ENABLE_CONFIG_FILES to NO. Specify -DTIDY_CONFIG_FILE and/or
|
|
|
|
# -DTIDY_USER_CONFIG_FILE to override the default paths in tidyplatform.h.
|
|
|
|
# @note: this section refactored to support #584.
|
2017-10-02 16:17:16 +00:00
|
|
|
#------------------------------------------------------------------------
|
2017-10-02 14:42:25 +00:00
|
|
|
if ( UNIX AND SUPPORT_CONSOLE_APP )
|
2017-09-30 21:06:19 +00:00
|
|
|
|
|
|
|
option ( ENABLE_CONFIG_FILES "Set to OFF to disable Tidy runtime configuration file support" ON )
|
|
|
|
|
2017-10-02 14:42:25 +00:00
|
|
|
# All Unixes support getpwnam(); undef'd in tidyplatform.h if necessary.
|
|
|
|
add_definitions( -DSUPPORT_GETPWNAM=1 )
|
|
|
|
|
|
|
|
else ()
|
|
|
|
|
|
|
|
option ( ENABLE_CONFIG_FILES "Set to ON to enable Tidy runtime configuration file support" OFF )
|
2017-09-30 21:06:19 +00:00
|
|
|
|
2017-10-02 14:42:25 +00:00
|
|
|
if ( SUPPORT_GETPWNAM )
|
|
|
|
add_definitions( -DSUPPORT_GETPWNAM=1 )
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if ( ENABLE_CONFIG_FILES )
|
|
|
|
|
2017-09-30 21:06:19 +00:00
|
|
|
message(STATUS "*** Building support for runtime configuration files.")
|
|
|
|
|
|
|
|
add_definitions( -DTIDY_ENABLE_CONFIG_FILES )
|
2017-10-02 16:54:03 +00:00
|
|
|
|
|
|
|
# define a default here so we can pass to XSL.
|
|
|
|
if ( NOT TIDY_CONFIG_FILE )
|
|
|
|
set( TIDY_CONFIG_FILE "/etc/tidy.conf" )
|
2017-09-30 21:06:19 +00:00
|
|
|
endif ()
|
2017-10-02 14:42:25 +00:00
|
|
|
|
2017-10-02 16:54:03 +00:00
|
|
|
# define a default here so we can pass to XSL.
|
|
|
|
if ( NOT TIDY_USER_CONFIG_FILE )
|
|
|
|
set( TIDY_USER_CONFIG_FILE "~/.tidyrc" )
|
2017-09-30 21:06:19 +00:00
|
|
|
endif ()
|
2015-03-19 15:32:19 +00:00
|
|
|
|
2017-10-02 16:54:03 +00:00
|
|
|
# do *not* add these unless ENABLE_CONFIG_FILES!
|
|
|
|
add_definitions( -DTIDY_CONFIG_FILE="${TIDY_CONFIG_FILE}" )
|
|
|
|
add_definitions( -DTIDY_USER_CONFIG_FILE="${TIDY_USER_CONFIG_FILE}" )
|
2017-09-30 21:06:19 +00:00
|
|
|
|
2017-10-02 14:42:25 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-09-30 21:06:19 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Shared Library
|
|
|
|
# Setup whether or not we will build the shared library.
|
|
|
|
#------------------------------------------------------------------------
|
2014-08-03 18:08:57 +00:00
|
|
|
if(BUILD_SHARED_LIB)
|
|
|
|
set(LIB_TYPE SHARED)
|
2015-06-09 10:17:43 +00:00
|
|
|
message(STATUS "*** Also building DLL library ${LIB_TYPE}, version ${LIBTIDY_VERSION}, date ${LIBTIDY_DATE}")
|
|
|
|
else()
|
|
|
|
message(STATUS "*** Only building static library ${LIB_TYPE}, version ${LIBTIDY_VERSION}, date ${LIBTIDY_DATE}")
|
|
|
|
endif()
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#################################################
|
|
|
|
# Build
|
|
|
|
#################################################
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# File Locations and File Lists
|
|
|
|
# Setup whether or not we will build the shared library.
|
|
|
|
#------------------------------------------------------------------------
|
2014-08-03 18:08:57 +00:00
|
|
|
include_directories ( "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/src" )
|
|
|
|
|
|
|
|
set ( SRCDIR src )
|
|
|
|
set ( INCDIR include )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2014-08-03 18:08:57 +00:00
|
|
|
set ( CFILES
|
|
|
|
${SRCDIR}/access.c ${SRCDIR}/attrs.c ${SRCDIR}/istack.c
|
|
|
|
${SRCDIR}/parser.c ${SRCDIR}/tags.c ${SRCDIR}/entities.c
|
2017-02-18 21:56:31 +00:00
|
|
|
${SRCDIR}/lexer.c ${SRCDIR}/pprint.c ${SRCDIR}/charsets.c
|
|
|
|
${SRCDIR}/clean.c ${SRCDIR}/message.c ${SRCDIR}/config.c
|
2017-11-18 02:39:30 +00:00
|
|
|
${SRCDIR}/alloc.c ${SRCDIR}/attrdict.c ${SRCDIR}/buffio.c
|
|
|
|
${SRCDIR}/fileio.c ${SRCDIR}/streamio.c ${SRCDIR}/tagask.c
|
|
|
|
${SRCDIR}/tmbstr.c ${SRCDIR}/utf8.c ${SRCDIR}/tidylib.c
|
|
|
|
${SRCDIR}/mappedio.c ${SRCDIR}/gdoc.c ${SRCDIR}/language.c
|
|
|
|
${SRCDIR}/messageobj.c ${SRCDIR}/sprtf.c )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2014-08-03 18:08:57 +00:00
|
|
|
set ( HFILES
|
2015-06-30 17:59:00 +00:00
|
|
|
${INCDIR}/tidyplatform.h ${INCDIR}/tidy.h ${INCDIR}/tidyenum.h
|
|
|
|
${INCDIR}/tidybuffio.h )
|
2016-06-13 09:10:16 +00:00
|
|
|
|
|
|
|
if (TIDY_COMPAT_HEADERS)
|
|
|
|
set ( HFILES ${HFILES} ${INCDIR}/buffio.h ${INCDIR}/platform.h )
|
|
|
|
endif ()
|
|
|
|
|
2014-08-03 18:08:57 +00:00
|
|
|
set ( LIBHFILES
|
|
|
|
${SRCDIR}/access.h ${SRCDIR}/attrs.h ${SRCDIR}/attrdict.h ${SRCDIR}/charsets.h
|
|
|
|
${SRCDIR}/clean.h ${SRCDIR}/config.h ${SRCDIR}/entities.h
|
|
|
|
${SRCDIR}/fileio.h ${SRCDIR}/forward.h ${SRCDIR}/lexer.h
|
|
|
|
${SRCDIR}/mappedio.h ${SRCDIR}/message.h ${SRCDIR}/parser.h
|
|
|
|
${SRCDIR}/pprint.h ${SRCDIR}/streamio.h ${SRCDIR}/tags.h
|
|
|
|
${SRCDIR}/tmbstr.h ${SRCDIR}/utf8.h ${SRCDIR}/tidy-int.h
|
2016-02-01 18:27:28 +00:00
|
|
|
${SRCDIR}/version.h ${SRCDIR}/gdoc.h ${SRCDIR}/language.h
|
2017-10-04 02:31:55 +00:00
|
|
|
${SRCDIR}/language_en.h ${SRCDIR}/sprtf.h )
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Target Locations
|
|
|
|
#------------------------------------------------------------------------
|
2015-11-13 18:33:27 +00:00
|
|
|
if (NOT LIB_INSTALL_DIR)
|
|
|
|
set(LIB_INSTALL_DIR lib${LIB_SUFFIX})
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (NOT BIN_INSTALL_DIR)
|
|
|
|
set(BIN_INSTALL_DIR bin)
|
|
|
|
endif ()
|
|
|
|
|
2015-11-13 19:19:10 +00:00
|
|
|
if (NOT INCLUDE_INSTALL_DIR)
|
2017-11-09 14:00:08 +00:00
|
|
|
set(INCLUDE_INSTALL_DIR include)
|
2015-11-13 19:19:10 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Static Library
|
|
|
|
# The static library always builds.
|
|
|
|
#------------------------------------------------------------------------
|
2015-05-24 13:10:31 +00:00
|
|
|
set(name tidy-static)
|
|
|
|
add_library ( ${name} STATIC ${CFILES} ${HFILES} ${LIBHFILES} )
|
2015-01-24 12:21:33 +00:00
|
|
|
set_target_properties( ${name} PROPERTIES
|
2017-10-02 16:17:16 +00:00
|
|
|
OUTPUT_NAME ${LIB_NAME}s )
|
2015-12-04 17:31:24 +00:00
|
|
|
if (NOT TIDY_CONSOLE_SHARED) # user wants default static linkage
|
|
|
|
list ( APPEND add_LIBS ${name} )
|
|
|
|
endif ()
|
2014-08-06 10:09:13 +00:00
|
|
|
install(TARGETS ${name}
|
2015-11-13 18:33:27 +00:00
|
|
|
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
|
|
|
|
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
|
|
|
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
2015-05-24 13:10:31 +00:00
|
|
|
)
|
2015-11-13 19:19:10 +00:00
|
|
|
install( FILES ${HFILES} DESTINATION ${INCLUDE_INSTALL_DIR} )
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Dynamic Library
|
|
|
|
# If the user option is still on.
|
|
|
|
#------------------------------------------------------------------------
|
2015-05-24 13:10:31 +00:00
|
|
|
if (BUILD_SHARED_LIB)
|
|
|
|
set(name tidy-share)
|
2017-10-03 12:57:11 +00:00
|
|
|
if (UNIX AND APPLE)
|
|
|
|
set(CMAKE_MACOSX_RPATH 1)
|
|
|
|
endif ()
|
2015-05-24 13:10:31 +00:00
|
|
|
add_library ( ${name} SHARED ${CFILES} ${HFILES} ${LIBHFILES} )
|
|
|
|
set_target_properties( ${name} PROPERTIES
|
2017-10-02 16:17:16 +00:00
|
|
|
OUTPUT_NAME ${LIB_NAME} )
|
2015-05-24 13:10:31 +00:00
|
|
|
set_target_properties( ${name} PROPERTIES
|
|
|
|
VERSION ${LIBTIDY_VERSION}
|
|
|
|
SOVERSION ${TIDY_MAJOR_VERSION} )
|
|
|
|
set_target_properties( ${name} PROPERTIES
|
|
|
|
COMPILE_FLAGS "-DBUILD_SHARED_LIB" )
|
|
|
|
set_target_properties( ${name} PROPERTIES
|
|
|
|
COMPILE_FLAGS "-DBUILDING_SHARED_LIB" )
|
|
|
|
install(TARGETS ${name}
|
2015-11-13 18:33:27 +00:00
|
|
|
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
|
|
|
|
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
|
|
|
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
2015-05-24 13:10:31 +00:00
|
|
|
)
|
2017-10-02 16:17:16 +00:00
|
|
|
if (TIDY_CONSOLE_SHARED) # user wants shared/dll linkage
|
2015-12-04 17:31:24 +00:00
|
|
|
list ( APPEND add_LIBS ${name} )
|
|
|
|
endif ()
|
2015-11-13 18:33:27 +00:00
|
|
|
endif ()
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Main Executable
|
|
|
|
# The main executable will be linked with either the static or the
|
|
|
|
# shared library.
|
|
|
|
#------------------------------------------------------------------------
|
2017-02-13 19:29:47 +00:00
|
|
|
if (SUPPORT_CONSOLE_APP)
|
|
|
|
set(name ${LIB_NAME})
|
|
|
|
set ( BINDIR console )
|
|
|
|
add_executable( ${name} ${BINDIR}/tidy.c )
|
|
|
|
target_link_libraries( ${name} ${add_LIBS} )
|
|
|
|
if (MSVC)
|
|
|
|
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
|
|
|
endif ()
|
2021-04-28 14:20:51 +00:00
|
|
|
if (APPLE)
|
|
|
|
target_link_options(${name} PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/console/Info.plist)
|
|
|
|
endif ()
|
2017-02-13 19:29:47 +00:00
|
|
|
if (NOT TIDY_CONSOLE_SHARED)
|
|
|
|
set_target_properties( ${name} PROPERTIES
|
|
|
|
COMPILE_FLAGS "-DTIDY_STATIC" )
|
|
|
|
endif ()
|
|
|
|
install (TARGETS ${name} DESTINATION bin)
|
2015-12-04 17:31:24 +00:00
|
|
|
endif ()
|
2014-08-03 18:08:57 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Miscellaneous Targets
|
|
|
|
#------------------------------------------------------------------------
|
2015-01-28 16:15:44 +00:00
|
|
|
if (BUILD_TAB2SPACE)
|
|
|
|
set(name tab2space)
|
|
|
|
add_executable( ${name} ${BINDIR}/tab2space.c )
|
|
|
|
if (MSVC)
|
|
|
|
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
|
|
|
endif ()
|
2015-12-04 17:31:24 +00:00
|
|
|
# no INSTALL of this 'local' tool - use depreciated
|
2014-08-03 18:08:57 +00:00
|
|
|
endif ()
|
|
|
|
|
2015-02-07 14:33:13 +00:00
|
|
|
if (BUILD_SAMPLE_CODE)
|
|
|
|
set(name test71)
|
|
|
|
set(dir console)
|
|
|
|
add_executable( ${name} ${dir}/${name}.cxx )
|
|
|
|
if (MSVC)
|
|
|
|
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
|
|
|
endif ()
|
|
|
|
target_link_libraries( ${name} ${add_LIBS} )
|
|
|
|
# no INSTALL of this 'local' sample
|
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#################################################
|
2015-03-07 22:08:39 +00:00
|
|
|
# Create man pages
|
2017-10-02 16:17:16 +00:00
|
|
|
#################################################
|
|
|
|
|
2017-02-13 19:29:47 +00:00
|
|
|
if (UNIX AND SUPPORT_CONSOLE_APP)
|
2015-03-07 22:08:39 +00:00
|
|
|
find_program( XSLTPROC_FOUND xsltproc )
|
|
|
|
if (XSLTPROC_FOUND)
|
2015-04-02 11:17:14 +00:00
|
|
|
## NOTE: man name must match exe ie currently `${LIB_NAME}.1` not `tidy.1`
|
2015-03-07 22:11:51 +00:00
|
|
|
## also could use `manpath` command output to determine target install path
|
2015-04-02 11:17:14 +00:00
|
|
|
set(TIDY_MANFILE ${LIB_NAME}.1)
|
2015-05-12 12:25:12 +00:00
|
|
|
message(STATUS "*** Generating man ${TIDY_MANFILE} custom commands...")
|
2015-10-02 12:21:15 +00:00
|
|
|
set(TIDY1XSL ${CMAKE_CURRENT_BINARY_DIR}/tidy1.xsl)
|
2015-09-29 21:39:08 +00:00
|
|
|
set(TIDYHELP ${CMAKE_CURRENT_BINARY_DIR}/tidy-help.xml)
|
|
|
|
set(TIDYCONFIG ${CMAKE_CURRENT_BINARY_DIR}/tidy-config.xml)
|
|
|
|
add_custom_target(man ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}")
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
## Populate the @VARIABLES@ in the input file.
|
2015-09-30 14:04:49 +00:00
|
|
|
configure_file(
|
2016-02-05 06:59:12 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/man/tidy1.xsl.in
|
2015-09-30 14:04:49 +00:00
|
|
|
${TIDY1XSL}
|
|
|
|
)
|
2015-03-08 05:39:46 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
# Run the built EXE to generate xml output .
|
2015-03-07 22:08:39 +00:00
|
|
|
add_custom_command(
|
2015-03-08 05:39:46 +00:00
|
|
|
TARGET man
|
2015-09-29 21:39:08 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-help > ${TIDYHELP}
|
2015-03-07 22:08:39 +00:00
|
|
|
COMMENT "Generate ${TIDYHELP}"
|
|
|
|
VERBATIM
|
2015-03-08 05:39:46 +00:00
|
|
|
)
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
# Run the built EXE to generate more xml output.
|
2015-03-08 07:39:48 +00:00
|
|
|
add_custom_command(
|
|
|
|
TARGET man
|
2015-09-29 21:39:08 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-config > ${TIDYCONFIG}
|
2015-03-08 11:35:41 +00:00
|
|
|
COMMENT "Generate ${TIDYCONFIG}"
|
2015-03-08 07:39:48 +00:00
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
# Run xsltproc to generate the install files.
|
2015-03-07 22:08:39 +00:00
|
|
|
add_custom_command(
|
|
|
|
TARGET man
|
2015-03-08 05:39:46 +00:00
|
|
|
DEPENDS ${TIDYHELP}
|
2015-09-29 21:39:08 +00:00
|
|
|
COMMAND xsltproc ARGS ${TIDY1XSL} ${TIDYHELP} > ${CMAKE_CURRENT_BINARY_DIR}/${TIDY_MANFILE}
|
2015-03-08 05:39:46 +00:00
|
|
|
COMMENT "Generate ${TIDY_MANFILE}"
|
2015-03-07 22:08:39 +00:00
|
|
|
VERBATIM
|
|
|
|
)
|
2015-03-08 05:39:46 +00:00
|
|
|
|
2015-09-29 21:39:08 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TIDY_MANFILE} DESTINATION ${MAN_INSTALL_DIR})
|
2016-02-05 06:59:12 +00:00
|
|
|
|
2015-05-12 12:25:12 +00:00
|
|
|
else ()
|
|
|
|
message(STATUS "*** NOTE: xsltproc NOT FOUND! Can NOT generate man page.")
|
|
|
|
message(STATUS "*** You need to install xsltproc in your system.")
|
2015-03-07 22:08:39 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#################################################
|
|
|
|
# Create MSI,EXE, DMG, DEB/RPM
|
|
|
|
# TODO: Check each of these builds
|
|
|
|
#################################################
|
|
|
|
|
2015-03-06 14:29:12 +00:00
|
|
|
set(BITNESS 32)
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(BITNESS 64)
|
|
|
|
endif()
|
2017-03-22 03:11:32 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# System Runtime Libraries
|
|
|
|
# Need to ensure that system DLLs get included in a binary
|
|
|
|
# distribution, but since it can miss some - seems incomplete - make
|
|
|
|
# optional.
|
|
|
|
#------------------------------------------------------------------------
|
2017-03-23 14:13:28 +00:00
|
|
|
option( ADD_SYSTEM_RUNTIMES "Set ON to include system runtime DLLS in distribution" OFF )
|
|
|
|
if (MSVC AND ADD_SYSTEM_RUNTIMES)
|
|
|
|
if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
|
|
|
|
# Visual Studio Express does include redistributable components so
|
|
|
|
# squelch the warning.
|
|
|
|
set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
|
|
|
endif ()
|
|
|
|
set (CMAKE_INSTALL_DEBUG_LIBRARIES OFF)
|
|
|
|
include (InstallRequiredSystemLibraries)
|
2017-10-02 16:17:16 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Windows
|
|
|
|
# MSI - this needs WiX Tooset installed and a path to candle.exe
|
|
|
|
# EXE - this needs NSIS tools to be in path
|
|
|
|
#------------------------------------------------------------------------
|
2015-03-06 14:29:12 +00:00
|
|
|
if (WIN32)
|
2015-03-20 12:56:20 +00:00
|
|
|
set(CPACK_GENERATOR "NSIS;WIX;ZIP")
|
2015-03-06 14:29:12 +00:00
|
|
|
set(CPACK_SOURCE_GENERATOR "ZIP")
|
|
|
|
set(CPACK_WIX_UPGRADE_GUID "D809598A-B513-4752-B268-0BAC403B00E4")
|
|
|
|
elseif ( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
|
2017-05-04 13:50:36 +00:00
|
|
|
set(CPACK_GENERATOR "productbuild")
|
2015-03-06 14:29:12 +00:00
|
|
|
set(CPACK_SOURCE_GENERATOR "TGZ")
|
|
|
|
else ()
|
|
|
|
set(CPACK_GENERATOR "DEB;RPM")
|
|
|
|
set(CPACK_SOURCE_GENERATOR "TGZ")
|
|
|
|
endif ()
|
2015-03-05 22:08:54 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# General
|
|
|
|
#------------------------------------------------------------------------
|
2015-04-02 11:17:14 +00:00
|
|
|
set(CPACK_PACKAGE_NAME "${LIB_NAME}")
|
2017-04-17 22:21:07 +00:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${LIBTIDY_DESCRIPTION}")
|
2015-03-05 22:08:54 +00:00
|
|
|
set(CPACK_PACKAGE_VENDOR "HTML Tidy Advocacy Community Group")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "maintainer@htacg.org")
|
|
|
|
|
|
|
|
set(CPACK_PACKAGE_VERSION ${LIBTIDY_VERSION})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${TIDY_MAJOR_VERSION}")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${TIDY_MINOR_VERSION}")
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "${TIDY_POINT_VERSION}")
|
2015-10-31 02:58:28 +00:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README/README.html")
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2017-03-23 14:05:05 +00:00
|
|
|
# use one compatible license file for all
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/README/LICENSE.txt")
|
2015-10-31 02:58:28 +00:00
|
|
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README/README.html")
|
|
|
|
set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/README/README.html")
|
2015-03-05 22:08:54 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# Debian
|
|
|
|
#------------------------------------------------------------------------
|
2015-03-05 22:08:54 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
|
2017-04-17 22:21:07 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${LIBTIDY_URL})
|
2015-03-05 22:08:54 +00:00
|
|
|
#set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries")
|
2017-03-22 03:11:32 +00:00
|
|
|
set(CPACK_SOURCE_IGNORE_FILES
|
|
|
|
"${PROJECT_SOURCE_DIR}/build"
|
|
|
|
)
|
2015-03-05 22:08:54 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
# RPM config
|
|
|
|
#------------------------------------------------------------------------
|
2016-02-04 07:40:49 +00:00
|
|
|
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/man" "/usr/share/man/man1")
|
|
|
|
|
2015-09-29 21:39:08 +00:00
|
|
|
set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/test/;${CMAKE_CURRENT_SOURCE_DIR}/build/;${CMAKE_CURRENT_SOURCE_DIR}/.git/")
|
2015-03-06 14:29:12 +00:00
|
|
|
|
|
|
|
if (NOT WIN32 AND NOT APPLE)
|
2015-04-02 11:17:14 +00:00
|
|
|
set( CPACK_PACKAGE_FILE_NAME "${LIB_NAME}-${CPACK_PACKAGE_VERSION}-${BITNESS}bit" )
|
2015-03-06 14:29:12 +00:00
|
|
|
endif ()
|
2015-03-05 22:08:54 +00:00
|
|
|
|
2015-03-06 14:29:12 +00:00
|
|
|
include(CPack)
|
2015-01-24 12:14:12 +00:00
|
|
|
|
2017-10-02 16:17:16 +00:00
|
|
|
#------------------------------------------------------------------------
|
2017-04-17 22:21:07 +00:00
|
|
|
# pkg-config
|
2017-10-02 16:17:16 +00:00
|
|
|
#------------------------------------------------------------------------
|
2017-04-17 22:21:07 +00:00
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.pc"
|
|
|
|
@ONLY
|
|
|
|
)
|
2017-10-02 16:17:16 +00:00
|
|
|
|
2017-04-17 22:21:07 +00:00
|
|
|
install(FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.pc"
|
2017-05-02 18:28:48 +00:00
|
|
|
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
|
2017-04-17 22:21:07 +00:00
|
|
|
)
|
|
|
|
|
2015-03-06 14:29:12 +00:00
|
|
|
# eof
|