Skip to content

Commit 319fe51

Browse files
authored
cmake : create solution folders (ggml-org#2004)
* Create solution folders in the CMake build. * Fixed non-SDL2 build. * Fixed emscripten build.
1 parent 13c2232 commit 319fe51

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required (VERSION 3.5)
22

3+
# Allow for the creation of solution folders.
4+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
5+
36
project(whisper.cpp VERSION 1.5.4)
47
set(SOVERSION 1)
58

@@ -561,6 +564,7 @@ if (WHISPER_COREML)
561564
set_target_properties(${TARGET} PROPERTIES
562565
COMPILE_FLAGS "-fobjc-arc"
563566
)
567+
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
564568
endif()
565569

566570
if (WHISPER_OPENVINO)
@@ -579,6 +583,7 @@ if (WHISPER_OPENVINO)
579583
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DWHISPER_USE_OPENVINO)
580584

581585
target_link_libraries(${TARGET} PRIVATE openvino::runtime)
586+
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
582587
endif()
583588

584589
#
@@ -677,6 +682,7 @@ target_compile_definitions(${TARGET} PUBLIC
677682
)
678683

679684
set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "ggml.h;whisper.h")
685+
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
680686

681687
include(GNUInstallDirs)
682688

examples/CMakeLists.txt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ include(DefaultTargetOptions)
3636
target_link_libraries(${TARGET} PRIVATE whisper)
3737

3838
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
39+
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
3940

4041
if (WHISPER_SDL2)
4142
# common-sdl
@@ -53,36 +54,63 @@ if (WHISPER_SDL2)
5354
target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES})
5455

5556
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
57+
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
5658
endif()
5759

5860
# add json lib
5961
add_library(json_cpp INTERFACE json.hpp)
62+
set_target_properties(json_cpp PROPERTIES FOLDER "libs")
6063

6164
# examples
6265

6366
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
6467

6568
if (EMSCRIPTEN)
6669
add_subdirectory(whisper.wasm)
70+
set_target_properties(libmain PROPERTIES FOLDER "libs")
6771
add_subdirectory(stream.wasm)
72+
set_target_properties(libstream PROPERTIES FOLDER "libs")
6873
add_subdirectory(command.wasm)
74+
set_target_properties(libcommand PROPERTIES FOLDER "libs")
6975
add_subdirectory(talk.wasm)
76+
set_target_properties(libtalk PROPERTIES FOLDER "libs")
7077
add_subdirectory(bench.wasm)
78+
set_target_properties(libbench PROPERTIES FOLDER "libs")
7179
elseif(CMAKE_JS_VERSION)
7280
add_subdirectory(addon.node)
81+
set_target_properties(addon.node PROPERTIES FOLDER "examples")
7382
else()
7483
add_subdirectory(main)
84+
set_target_properties(main PROPERTIES FOLDER "examples")
85+
if (WHISPER_SDL2)
7586
add_subdirectory(stream)
87+
set_target_properties(stream PROPERTIES FOLDER "examples")
88+
endif (WHISPER_SDL2)
7689
add_subdirectory(server)
90+
set_target_properties(server PROPERTIES FOLDER "examples")
91+
if (WHISPER_SDL2)
7792
add_subdirectory(command)
93+
set_target_properties(command PROPERTIES FOLDER "examples")
94+
endif (WHISPER_SDL2)
7895
add_subdirectory(bench)
96+
set_target_properties(bench PROPERTIES FOLDER "examples")
7997
add_subdirectory(quantize)
98+
set_target_properties(quantize PROPERTIES FOLDER "examples")
99+
if (WHISPER_SDL2)
80100
add_subdirectory(talk)
101+
set_target_properties(talk PROPERTIES FOLDER "examples")
81102
add_subdirectory(talk-llama)
103+
set_target_properties(talk-llama PROPERTIES FOLDER "examples")
82104
add_subdirectory(lsp)
105+
set_target_properties(lsp PROPERTIES FOLDER "examples")
83106
if (LLAMA_SYCL)
84107
add_subdirectory(sycl)
108+
set_target_properties(sycl PROPERTIES FOLDER "examples")
85109
endif()
110+
endif (WHISPER_SDL2)
86111
endif()
87112

88-
add_subdirectory(wchess)
113+
if (WHISPER_SDL2)
114+
add_subdirectory(wchess)
115+
set_target_properties(wchess PROPERTIES FOLDER "examples")
116+
endif (WHISPER_SDL2)

examples/wchess/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
add_subdirectory(libwchess)
2+
set_target_properties(wchess-core PROPERTIES FOLDER "libs")
23

34
if (EMSCRIPTEN)
45
add_subdirectory(wchess.wasm)
6+
set_target_properties(wchess.wasm PROPERTIES FOLDER "libs")
57
else()
68
add_subdirectory(wchess.cmd)
9+
set_target_properties(wchess PROPERTIES FOLDER "libs")
710
endif()

0 commit comments

Comments
 (0)