Andy Maloney commited on
Commit
37e2420
·
unverified ·
1 Parent(s): 763a6f3

cmake : update to 3.19 (#351)

Browse files

- update from 3.0 (from 2014) to 3.19 (from 2020)
- move some global setting onto the targets (through a cmake include)

CMakeLists.txt CHANGED
@@ -1,15 +1,14 @@
1
- cmake_minimum_required (VERSION 3.0)
2
 
3
  project(whisper.cpp VERSION 1.0.4)
4
 
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")
8
 
9
  if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
10
  set(WHISPER_STANDALONE ON)
11
- include(cmake/GitVars.cmake)
12
- include(cmake/BuildTypes.cmake)
13
 
14
  # configure project version
15
  if (EXISTS "${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl")
@@ -82,9 +81,6 @@ endif()
82
 
83
  # dependencies
84
 
85
- set(CMAKE_C_STANDARD 11)
86
- set(CMAKE_CXX_STANDARD 11)
87
-
88
  find_package(Threads REQUIRED)
89
 
90
  # on APPLE - include Accelerate framework
@@ -190,6 +186,8 @@ add_library(${TARGET}
190
  whisper.cpp
191
  )
192
 
 
 
193
  target_include_directories(${TARGET} PUBLIC
194
  .
195
  )
 
1
+ cmake_minimum_required (VERSION 3.19)
2
 
3
  project(whisper.cpp VERSION 1.0.4)
4
 
5
+ # Add path to modules
6
+ list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
 
7
 
8
  if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
9
  set(WHISPER_STANDALONE ON)
10
+ include(GitVars)
11
+ include(BuildTypes)
12
 
13
  # configure project version
14
  if (EXISTS "${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl")
 
81
 
82
  # dependencies
83
 
 
 
 
84
  find_package(Threads REQUIRED)
85
 
86
  # on APPLE - include Accelerate framework
 
186
  whisper.cpp
187
  )
188
 
189
+ include(DefaultTargetOptions)
190
+
191
  target_include_directories(${TARGET} PUBLIC
192
  .
193
  )
cmake/DefaultTargetOptions.cmake ADDED
@@ -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 CHANGED
@@ -8,6 +8,8 @@ add_executable(${TARGET}
8
  emscripten.cpp
9
  )
10
 
 
 
11
  target_link_libraries(${TARGET} PRIVATE
12
  whisper
13
  )
 
8
  emscripten.cpp
9
  )
10
 
11
+ include(DefaultTargetOptions)
12
+
13
  target_link_libraries(${TARGET} PRIVATE
14
  whisper
15
  )
examples/bench/CMakeLists.txt CHANGED
@@ -1,3 +1,6 @@
1
  set(TARGET bench)
2
  add_executable(${TARGET} bench.cpp)
 
 
 
3
  target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})
 
1
  set(TARGET bench)
2
  add_executable(${TARGET} bench.cpp)
3
+
4
+ include(DefaultTargetOptions)
5
+
6
  target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})
examples/command.wasm/CMakeLists.txt CHANGED
@@ -8,6 +8,8 @@ add_executable(${TARGET}
8
  emscripten.cpp
9
  )
10
 
 
 
11
  target_link_libraries(${TARGET} PRIVATE
12
  whisper
13
  )
 
8
  emscripten.cpp
9
  )
10
 
11
+ include(DefaultTargetOptions)
12
+
13
  target_link_libraries(${TARGET} PRIVATE
14
  whisper
15
  )
examples/command/CMakeLists.txt CHANGED
@@ -2,6 +2,9 @@ if (WHISPER_SUPPORT_SDL2)
2
  # command
3
  set(TARGET command)
4
  add_executable(${TARGET} command.cpp)
 
 
 
5
  target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
6
  target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
7
  endif ()
 
2
  # command
3
  set(TARGET command)
4
  add_executable(${TARGET} command.cpp)
5
+
6
+ include(DefaultTargetOptions)
7
+
8
  target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
9
  target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
10
  endif ()
examples/main/CMakeLists.txt CHANGED
@@ -1,3 +1,6 @@
1
  set(TARGET main)
2
  add_executable(${TARGET} main.cpp)
 
 
 
3
  target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})
 
1
  set(TARGET main)
2
  add_executable(${TARGET} main.cpp)
3
+
4
+ include(DefaultTargetOptions)
5
+
6
  target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})
examples/stream.wasm/CMakeLists.txt CHANGED
@@ -8,6 +8,8 @@ add_executable(${TARGET}
8
  emscripten.cpp
9
  )
10
 
 
 
11
  target_link_libraries(${TARGET} PRIVATE
12
  whisper
13
  )
 
8
  emscripten.cpp
9
  )
10
 
11
+ include(DefaultTargetOptions)
12
+
13
  target_link_libraries(${TARGET} PRIVATE
14
  whisper
15
  )
examples/stream/CMakeLists.txt CHANGED
@@ -2,6 +2,9 @@ if (WHISPER_SUPPORT_SDL2)
2
  # stream
3
  set(TARGET stream)
4
  add_executable(${TARGET} stream.cpp)
 
 
 
5
  target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
6
  target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
7
  endif ()
 
2
  # stream
3
  set(TARGET stream)
4
  add_executable(${TARGET} stream.cpp)
5
+
6
+ include(DefaultTargetOptions)
7
+
8
  target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
9
  target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
10
  endif ()
examples/talk.wasm/CMakeLists.txt CHANGED
@@ -9,6 +9,8 @@ add_executable(${TARGET}
9
  gpt-2.cpp
10
  )
11
 
 
 
12
  target_link_libraries(${TARGET} PRIVATE
13
  whisper
14
  )
 
9
  gpt-2.cpp
10
  )
11
 
12
+ include(DefaultTargetOptions)
13
+
14
  target_link_libraries(${TARGET} PRIVATE
15
  whisper
16
  )
examples/talk/CMakeLists.txt CHANGED
@@ -8,6 +8,9 @@ if (WHISPER_SUPPORT_SDL2)
8
  # TODO: this is temporary
9
  # need to export ggml symbols for MSVC, but too lazy ..
10
  add_executable(${TARGET} talk.cpp gpt-2.cpp ../../ggml.c ../../whisper.cpp)
 
 
 
11
  target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS} ../../)
12
  target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
13
  endif ()
 
8
  # TODO: this is temporary
9
  # need to export ggml symbols for MSVC, but too lazy ..
10
  add_executable(${TARGET} talk.cpp gpt-2.cpp ../../ggml.c ../../whisper.cpp)
11
+
12
+ include(DefaultTargetOptions)
13
+
14
  target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS} ../../)
15
  target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
16
  endif ()
examples/whisper.wasm/CMakeLists.txt CHANGED
@@ -8,6 +8,8 @@ add_executable(${TARGET}
8
  emscripten.cpp
9
  )
10
 
 
 
11
  target_link_libraries(${TARGET} PRIVATE
12
  whisper
13
  )
 
8
  emscripten.cpp
9
  )
10
 
11
+ include(DefaultTargetOptions)
12
+
13
  target_link_libraries(${TARGET} PRIVATE
14
  whisper
15
  )