Skip to content

Commit

Permalink
Find gperf through find_program.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 02dcf7f4564152f25a0533f107671f142b6618f9
  • Loading branch information
levlam committed Feb 4, 2018
1 parent 6c706f4 commit a0fdce5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tdutils/generate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ set(TDMIME_AUTO
add_custom_target(tdmime_auto DEPENDS ${TDMIME_SOURCE})

if (NOT CMAKE_CROSSCOMPILING)
find_program(GPERF_EXECUTABLE gperf)
if(NOT GPERF_EXECUTABLE)
message(FATAL_ERROR "Could NOT find gperf. Path to gperf needs to be specified manually, i.e. 'cmake -DGPERF_EXECUTABLE:FILEPATH=\"<path to gperf executable>\" .')")
endif()

set(GPERF_FILES
${CMAKE_CURRENT_SOURCE_DIR}/auto/mime_type_to_extension.gperf
${CMAKE_CURRENT_SOURCE_DIR}/auto/extension_to_mime_type.gperf
Expand All @@ -34,9 +39,9 @@ if (NOT CMAKE_CROSSCOMPILING)
)

if (WIN32)
set(MIME_TYPE_TO_EXTENSION_CMD powershell -ExecutionPolicy ByPass \" & gperf -m100 --output-file=auto/mime_type_to_extension.cpp auto/mime_type_to_extension.gperf\")
set(MIME_TYPE_TO_EXTENSION_CMD ${GPERF_EXECUTABLE} -m100 --output-file=auto/mime_type_to_extension.cpp auto/mime_type_to_extension.gperf)
else()
set(MIME_TYPE_TO_EXTENSION_CMD gperf -m100 auto/mime_type_to_extension.gperf | grep -v __gnu_inline__ > auto/mime_type_to_extension.cpp)
set(MIME_TYPE_TO_EXTENSION_CMD ${GPERF_EXECUTABLE} -m100 auto/mime_type_to_extension.gperf | grep -v __gnu_inline__ > auto/mime_type_to_extension.cpp)
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/auto/mime_type_to_extension.cpp
Expand All @@ -46,9 +51,9 @@ if (NOT CMAKE_CROSSCOMPILING)
)

if (WIN32)
set(EXTENSION_TO_MIME_TYPE_CMD powershell -ExecutionPolicy ByPass \" & gperf -m100 --output-file=auto/extension_to_mime_type.cpp auto/extension_to_mime_type.gperf\")
set(EXTENSION_TO_MIME_TYPE_CMD ${GPERF_EXECUTABLE} -m100 --output-file=auto/extension_to_mime_type.cpp auto/extension_to_mime_type.gperf)
else()
set(EXTENSION_TO_MIME_TYPE_CMD gperf -m100 auto/extension_to_mime_type.gperf | grep -v __gnu_inline__ > auto/extension_to_mime_type.cpp)
set(EXTENSION_TO_MIME_TYPE_CMD ${GPERF_EXECUTABLE} -m100 auto/extension_to_mime_type.gperf | grep -v __gnu_inline__ > auto/extension_to_mime_type.cpp)
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/auto/extension_to_mime_type.cpp
Expand Down

0 comments on commit a0fdce5

Please sign in to comment.