Build pcre2 and muparser with CMake

This adds files MuParser.cmake and PCRE2.cmake. PCRE2 is built using
its own CMake path, while MuParser uses ExternalProject.
This commit is contained in:
ridiculousfish 2017-10-04 20:31:35 -07:00
parent 9f8ae95b0e
commit fe37a1646d
3 changed files with 53 additions and 6 deletions

28
CMakeFiles/MuParser.cmake Normal file
View file

@ -0,0 +1,28 @@
INCLUDE(ExternalProject)
SET(MUPARSER_PREFIX muparser-build)
SET(MUPARSER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/muparser-2.2.5)
SET(MUPARSER_OBJ ${MUPARSER_PREFIX}/obj)
SET(MUPARSER_DST ${MUPARSER_PREFIX}/dst)
# MuParser configure has an obnoxious victory message which we suppress.
EXTERNALPROJECT_ADD(
muparser_project
PREFIX ${MUPARSER_PREFIX}
SOURCE_DIR ${MUPARSER_SRC}
BINARY_DIR ${MUPARSER_OBJ}
INSTALL_DIR ${MUPARSER_DST}
CONFIGURE_COMMAND ${MUPARSER_SRC}/configure
--prefix=${CMAKE_CURRENT_BINARY_DIR}/${MUPARSER_DST}
--quiet --enable-shared=no --enable-samples=no --enable-debug=no > /dev/null
BUILD_COMMAND make -j 3 CPPFLAGS=-D_UNICODE=1\ -Wno-switch lib/libmuparser.a
INSTALL_COMMAND make install
BUILD_BYPRODUCTS ${MUPARSER_DST}/lib/libmuparser.a
EXCLUDE_FROM_ALL
)
ADD_LIBRARY(muparser STATIC IMPORTED)
SET_TARGET_PROPERTIES(muparser PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_BINARY_DIR}/${MUPARSER_DST}/lib/libmuparser.a)
ADD_DEPENDENCIES(muparser muparser_project)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/${MUPARSER_DST}/include/)

20
CMakeFiles/PCRE2.cmake Normal file
View file

@ -0,0 +1,20 @@
# PCRE2 needs some settings.
SET(PCRE2_WIDTH ${WCHAR_T_BITS})
SET(PCRE2_BUILD_PCRE2_8 OFF CACHE BOOL "Build 8bit PCRE2 library")
SET(PCRE2_BUILD_PCRE2_${PCRE2_WIDTH} ON CACHE BOOL "Build ${PCRE2_WIDTH}bit PCRE2 library")
SET(PCRE2_SHOW_REPORT OFF CACHE BOOL "Show the final configuration report")
SET(PCRE2_BUILD_PCRE2GREP OFF CACHE BOOL "Build pcre2grep")
SET(PCRE2_MIN_VERSION 10.21)
FIND_LIBRARY(PCRE2_LIB pcre2-${PCRE2_WIDTH})
FIND_PATH(PCRE2_INCLUDE_DIR pcre2.h)
IF (PCRE2_LIB AND PCRE2_INCLUDE_DIR)
MESSAGE(STATUS "Found system PCRE2 library ${PCRE2_INCLUDE_DIR}")
ELSE()
MESSAGE(STATUS "Using bundled PCRE2 library")
ADD_SUBDIRECTORY(pcre2-10.22 EXCLUDE_FROM_ALL)
SET(PCRE2_INCLUDE_DIR ${CMAKE_BINARY_DIR}/pcre2-10.22/)
SET(PCRE2_LIB pcre2-${PCRE2_WIDTH})
endif(PCRE2_LIB AND PCRE2_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${PCRE2_INCLUDE_DIR})

View file

@ -53,17 +53,16 @@ ADD_DEFINITIONS(-D_UNICODE=1
-DBINDIR=L"${CMAKE_INSTALL_FULL_BINDIR}"
-DDOCDIR=L"${CMAKE_INSTALL_FULL_DOCDIR}")
# Set up dependency paths.
INCLUDE_DIRECTORIES(muparser-2.2.5/include/ pcre2-10.22/src/)
LINK_DIRECTORIES(muparser-2.2.5/lib/ pcre2-10.22/.libs/)
# Set up PCRE2
INCLUDE(CMakeFiles/PCRE2.cmake)
# PCRE2 needs a define.
SET(PCRE2_WIDTH ${WCHAR_T_BITS})
# Set up muparser.
INCLUDE(CMakeFiles/MuParser.cmake)
# Define a function to link dependencies.
FUNCTION(FISH_LINK_DEPS target)
TARGET_LINK_LIBRARIES(${target} ${CURSES_LIBRARIES} Threads::Threads)
TARGET_LINK_LIBRARIES(${target} pcre2-${PCRE2_WIDTH} muparser)
TARGET_LINK_LIBRARIES(${target} ${PCRE2_LIB} muparser)
ENDFUNCTION(FISH_LINK_DEPS)
# Define fish.