build/windows: Add CMakeLists.txt for gperf

This commit is contained in:
b-r-o-c-k 2018-03-17 16:20:31 -05:00
parent 229604213e
commit feee814b30
3 changed files with 46 additions and 8 deletions

View File

@ -29,6 +29,7 @@ set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads" CACHE PATH "Dependencies dow
option(USE_BUNDLED "Use bundled dependencies." ON) option(USE_BUNDLED "Use bundled dependencies." ON)
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ${USE_BUNDLED})
option(USE_BUNDLED_JEMALLOC "Use the bundled jemalloc." ${USE_BUNDLED}) option(USE_BUNDLED_JEMALLOC "Use the bundled jemalloc." ${USE_BUNDLED})
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED}) option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED}) option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
@ -42,12 +43,6 @@ option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
# build it unless explicitly requested # build it unless explicitly requested
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF) option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
if(USE_BUNDLED AND (NOT WIN32))
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ON)
else()
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." OFF)
endif()
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF) option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
if(WIN32) if(WIN32)

View File

@ -36,8 +36,6 @@ function(BuildGperf)
INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}") INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}")
endfunction() endfunction()
set(GPERF_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING)) if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
BuildGperf( BuildGperf(
@ -45,6 +43,21 @@ if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
--prefix=${HOSTDEPS_INSTALL_DIR} --prefix=${HOSTDEPS_INSTALL_DIR}
INSTALL_COMMAND ${MAKE_PRG} install) INSTALL_COMMAND ${MAKE_PRG} install)
elseif(MSVC OR MINGW)
BuildGperf(
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/cmake/GperfCMakeLists.txt
${DEPS_BUILD_DIR}/src/gperf/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/gperf/CMakeLists.txt
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
else() else()
message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}") message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
endif() endif()

30
third-party/cmake/GperfCMakeLists.txt vendored Normal file
View File

@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 2.8.7)
project(gperf LANGUAGES C CXX)
add_executable(gperf
lib/getline.cc
lib/hash.cc
lib/getopt.c
lib/getopt1.c
src/version.cc
src/positions.cc
src/options.cc
src/keyword.cc
src/keyword-list.cc
src/input.cc
src/bool-array.cc
src/hash-table.cc
src/search.cc
src/output.cc
src/main.cc)
include_directories(lib)
# Copy the config.h template without modifying it
# because none of the definitions are necessary
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/src/config.h.in ${CMAKE_BINARY_DIR}/config/config.h)
include_directories(${CMAKE_BINARY_DIR}/config)
include(GNUInstallDirs)
install(TARGETS gperf
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})