Skip to content

Commit 84c6b42

Browse files
authored
cmake : update to 3.19 (#351)
- update from 3.0 (from 2014) to 3.19 (from 2020) - move some global setting onto the targets (through a cmake include)
1 parent dd6d582 commit 84c6b42

File tree

12 files changed

+49
-9
lines changed

12 files changed

+49
-9
lines changed

CMakeLists.txt

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
cmake_minimum_required (VERSION 3.0)
1+
cmake_minimum_required (VERSION 3.19)
22

33
project(whisper.cpp VERSION 1.0.4)
44

5-
set(CMAKE_EXPORT_COMPILE_COMMANDS "on")
6-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
7-
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
5+
# Add path to modules
6+
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
87

98
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
109
set(WHISPER_STANDALONE ON)
11-
include(cmake/GitVars.cmake)
12-
include(cmake/BuildTypes.cmake)
10+
include(GitVars)
11+
include(BuildTypes)
1312

1413
# configure project version
1514
if (EXISTS "${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl")
@@ -82,9 +81,6 @@ endif()
8281

8382
# dependencies
8483

85-
set(CMAKE_C_STANDARD 11)
86-
set(CMAKE_CXX_STANDARD 11)
87-
8884
find_package(Threads REQUIRED)
8985

9086
# on APPLE - include Accelerate framework
@@ -190,6 +186,8 @@ add_library(${TARGET}
190186
whisper.cpp
191187
)
192188

189+
include(DefaultTargetOptions)
190+
193191
target_include_directories(${TARGET} PUBLIC
194192
.
195193
)

cmake/DefaultTargetOptions.cmake

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set the default compile features and properties for a target.
2+
3+
if (NOT TARGET)
4+
message(FATAL_ERROR "TARGET not set before including DefaultTargetOptions")
5+
endif()
6+
7+
target_compile_features(${TARGET}
8+
PRIVATE
9+
cxx_std_11
10+
)
11+
12+
set_target_properties(${TARGET}
13+
PROPERTIES
14+
EXPORT_COMPILE_COMMANDS ON
15+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
16+
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
17+
)

examples/bench.wasm/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ add_executable(${TARGET}
88
emscripten.cpp
99
)
1010

11+
include(DefaultTargetOptions)
12+
1113
target_link_libraries(${TARGET} PRIVATE
1214
whisper
1315
)

examples/bench/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
set(TARGET bench)
22
add_executable(${TARGET} bench.cpp)
3+
4+
include(DefaultTargetOptions)
5+
36
target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})

examples/command.wasm/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ add_executable(${TARGET}
88
emscripten.cpp
99
)
1010

11+
include(DefaultTargetOptions)
12+
1113
target_link_libraries(${TARGET} PRIVATE
1214
whisper
1315
)

examples/command/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ if (WHISPER_SUPPORT_SDL2)
22
# command
33
set(TARGET command)
44
add_executable(${TARGET} command.cpp)
5+
6+
include(DefaultTargetOptions)
7+
58
target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
69
target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
710
endif ()

examples/main/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
set(TARGET main)
22
add_executable(${TARGET} main.cpp)
3+
4+
include(DefaultTargetOptions)
5+
36
target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})

examples/stream.wasm/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ add_executable(${TARGET}
88
emscripten.cpp
99
)
1010

11+
include(DefaultTargetOptions)
12+
1113
target_link_libraries(${TARGET} PRIVATE
1214
whisper
1315
)

examples/stream/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ if (WHISPER_SUPPORT_SDL2)
22
# stream
33
set(TARGET stream)
44
add_executable(${TARGET} stream.cpp)
5+
6+
include(DefaultTargetOptions)
7+
58
target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
69
target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
710
endif ()

examples/talk.wasm/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ add_executable(${TARGET}
99
gpt-2.cpp
1010
)
1111

12+
include(DefaultTargetOptions)
13+
1214
target_link_libraries(${TARGET} PRIVATE
1315
whisper
1416
)

examples/talk/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ if (WHISPER_SUPPORT_SDL2)
88
# TODO: this is temporary
99
# need to export ggml symbols for MSVC, but too lazy ..
1010
add_executable(${TARGET} talk.cpp gpt-2.cpp ../../ggml.c ../../whisper.cpp)
11+
12+
include(DefaultTargetOptions)
13+
1114
target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS} ../../)
1215
target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
1316
endif ()

examples/whisper.wasm/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ add_executable(${TARGET}
88
emscripten.cpp
99
)
1010

11+
include(DefaultTargetOptions)
12+
1113
target_link_libraries(${TARGET} PRIVATE
1214
whisper
1315
)

0 commit comments

Comments
 (0)