aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--third-party/CMakeLists.txt7
-rw-r--r--third-party/cmake/BuildGperf.cmake17
-rw-r--r--third-party/cmake/GperfCMakeLists.txt30
3 files changed, 46 insertions, 8 deletions
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 7c95bbb91d..cb4171f665 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -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_GPERF "Use the bundled version of gperf." ${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_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
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)
if(WIN32)
diff --git a/third-party/cmake/BuildGperf.cmake b/third-party/cmake/BuildGperf.cmake
index 494d0d9717..fd11aa1998 100644
--- a/third-party/cmake/BuildGperf.cmake
+++ b/third-party/cmake/BuildGperf.cmake
@@ -36,8 +36,6 @@ function(BuildGperf)
INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}")
endfunction()
-set(GPERF_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
-
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
BuildGperf(
@@ -45,6 +43,21 @@ if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
--prefix=${HOSTDEPS_INSTALL_DIR}
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()
message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
endif()
diff --git a/third-party/cmake/GperfCMakeLists.txt b/third-party/cmake/GperfCMakeLists.txt
new file mode 100644
index 0000000000..32837fc166
--- /dev/null
+++ b/third-party/cmake/GperfCMakeLists.txt
@@ -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})