Skip to content

Commit

Permalink
fixed #15 support for zlib Debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddie Wu committed Aug 21, 2023
1 parent 3029d23 commit 860e22f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
43 changes: 27 additions & 16 deletions kdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,48 @@ target_sources(PluginKDB PUBLIC ${PluginKDB_HEADER} PRIVATE ${PluginKDB_SOURCE})
target_compile_options(PluginKDB PRIVATE -Wall)

#=== Build Types
if ("${CMAKE_BUILD_TYPE}" MATCHES Debug)
set(optimize_opts -g -O0)
set(dep_debug_tag "d")
elseif("${CMAKE_BUILD_TYPE}" MATCHES Release)
set(optimize_opts -O3 )
set(dep_debug_tag "")
elseif("${CMAKE_BUILD_TYPE}" MATCHES RelWithDebInfo)
set(optimize_opts -g -O2)
set(dep_debug_tag "")
else()
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif()

target_compile_options(PluginKDB PRIVATE ${optimize_opts})
if(WIN32)
set(platform_macro WINDOWS)
set(install_type win)
set(kdb_lib "${PROJECT_SOURCE_DIR}/lib/w64/c.lib")
configure_file(
"${PROJECT_SOURCE_DIR}/PluginKDB_WIN32.txt"
"${PROJECT_BINARY_DIR}/PluginKDB.txt" COPYONLY)
#FIXME: CMake 3.21 offers better way to do this: install(IMPORTED_RUNTIME_ARTIFACTS ...)
configure_file(
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/zlib1.dll"
"${PROJECT_BINARY_DIR}/zlib${dep_debug_tag}1.dll" COPYONLY)
set(extra_bin
"${PROJECT_SOURCE_DIR}/lib/w64/c.dll"
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/zlib1.dll"
) #FIXME: CMake 3.21 offers better way to do this!
configure_file("${PROJECT_SOURCE_DIR}/PluginKDB_WIN32.txt" "${PROJECT_BINARY_DIR}/PluginKDB.txt" COPYONLY)
"${PROJECT_BINARY_DIR}/zlib${dep_debug_tag}1.dll"
)
elseif(UNIX)
set(platform_macro LINUX)
set(install_type linux)
set(kdb_lib "${PROJECT_SOURCE_DIR}/lib/c.o")
configure_file(
"${PROJECT_SOURCE_DIR}/PluginKDB.txt"
"${PROJECT_BINARY_DIR}/PluginKDB.txt" COPYONLY)
set(extra_bin )
configure_file("${PROJECT_SOURCE_DIR}/PluginKDB.txt" "${PROJECT_BINARY_DIR}/PluginKDB.txt" COPYONLY)
else()
message(FATAL_ERROR "FIXME: Add build support for this platform!")
endif()
target_compile_definitions(PluginKDB PUBLIC ${platform_macro})

if ("${CMAKE_BUILD_TYPE}" MATCHES Debug)
set(optimize_opts -g -O0)
elseif("${CMAKE_BUILD_TYPE}" MATCHES Release)
set(optimize_opts -O3 )
elseif("${CMAKE_BUILD_TYPE}" MATCHES RelWithDebInfo)
set(optimize_opts -g -O2)
else()
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif()
target_compile_options(PluginKDB PRIVATE ${optimize_opts})

#=== ASAN or not?
if (${DDB_USE_ASAN})
target_compile_options(PluginKDB PRIVATE
Expand Down Expand Up @@ -88,7 +99,7 @@ target_link_libraries (PluginKDB PRIVATE DolphinDB)

#== zlib
find_package(ZLIB REQUIRED)
target_link_libraries (PluginKDB PRIVATE ZLIB::ZLIB)
target_link_libraries(PluginKDB PRIVATE ZLIB::ZLIB)

#== kdb+
target_compile_definitions(PluginKDB PUBLIC KXVER=3)
Expand Down
9 changes: 8 additions & 1 deletion kdb/CMake_mingw+vcpkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ SET DOLPHINDB_ROOT=<path_to_DolphinDB>

```batch
del /S /Q build
:: Release mode
cmake -S . -B build -G Ninja
cmake --build build
:: Debug mode
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
:: RelWithDebInfo mode
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j 4
cmake --install build
```

0 comments on commit 860e22f

Please sign in to comment.