Skip to content

Commit 11633cb

Browse files
committed
build: support BUILD_SHARED_LIBS and set default CMAKE_BUILD_TYPE
1 parent ff7c065 commit 11633cb

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.28)
22

33
project(vision.cpp VERSION 0.2.0 LANGUAGES CXX)
44

5+
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries" ON)
56
option(VISP_VULKAN "Enable Vulkan support" OFF)
67
option(VISP_DEV "Enable development mode" OFF)
78
option(VISP_CI "Enable for continuous integration environment" OFF)
@@ -16,6 +17,12 @@ if(PROJECT_IS_TOP_LEVEL)
1617
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1718
endif()
1819

20+
# Set default build type to Release (except for multi-config generators)
21+
if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
22+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
23+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
24+
endif()
25+
1926
# Configure assertions
2027

2128
if(VISP_DEV)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ cd vision.cpp
151151

152152
**Configure and build**
153153
```sh
154-
cmake . -B build -D CMAKE_BUILD_TYPE=Release
154+
cmake . -B build
155155
cmake --build build --config Release
156156
```
157157

@@ -160,7 +160,7 @@ cmake --build build --config Release
160160
Building with Vulkan GPU support requires the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) to be installed.
161161

162162
```sh
163-
cmake . -B build -D CMAKE_BUILD_TYPE=Release -D VISP_VULKAN=ON
163+
cmake . -B build -D VISP_VULKAN=ON
164164
```
165165

166166
### Tests _(Optional)_

src/visp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_library(visioncpp SHARED)
1+
add_library(visioncpp)
22

33
target_sources(visioncpp PRIVATE
44
arch/birefnet.cpp

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ include(reference-images.cmake)
3838
#
3939
# Workbench library for Python tests
4040

41-
add_library(vision-workbench workbench.cpp)
41+
add_library(vision-workbench SHARED workbench.cpp)
4242
target_include_directories(vision-workbench PRIVATE ../src)
4343
target_compile_definitions(vision-workbench PRIVATE ${VISP_ASSERT} ${VISP_DEFINITIONS})
4444
target_compile_options(vision-workbench PRIVATE ${VISP_COMP_OPTIONS})

0 commit comments

Comments
 (0)