Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
utelle committed Nov 17, 2023
2 parents 60ea8e7 + 2c7a517 commit dce73ee
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OPTION(SQLITE_ENABLE_REGEXP "Enable extension 'regexp'" ON)
OPTION(SQLITE_ENABLE_SERIES "Enable extension 'series'" ON)
OPTION(SQLITE_ENABLE_SHA3 "Enable extension 'sha3'" ON)

# Options for shell only (compatibility with official SQLite shell
# Options for shell only (compatibility with official SQLite shell)
OPTION(SQLITE_ENABLE_EXPLAIN_COMMENTS "Insert comment text into the output of EXPLAIN (shell only)" ON)
OPTION(SQLITE_ENABLE_DBPAGE_VTAB "Enable the SQLITE_DBPAGE virtual table (shell only)" ON)
OPTION(SQLITE_ENABLE_DBSTAT_VTAB "Enable the dbstat virtual table (shell only)" ON)
Expand Down Expand Up @@ -209,6 +209,14 @@ endif()
# Only generate Debug and Release configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)

set(SQLITE3MC_PUBLIC_HEADERS
src/sqlite3.h
src/sqlite3ext.h
src/sqlite3mc.h
src/sqlite3mc_vfs.h
src/sqlite3userauth.h
)

set(SQLITE3MC_BASE_SRCS
src/sqlite3mc.c
src/cipher_common.h
Expand All @@ -218,15 +226,10 @@ set(SQLITE3MC_BASE_SRCS
src/rijndael.h
src/sha1.h
src/sha2.h
src/sqlite3.h
src/sqlite3ext.h
src/sqlite3mc.h
src/sqlite3mc_vfs.h
src/sqlite3userauth.h
src/test_windirent.h
${SQLITE3MC_PUBLIC_HEADERS}
)
set(SQLITE3MC_DLLRES_SRCS
src/sqlite3mc.def
src/sqlite3mc.rc
)
set(SQLITE3MC_SHELL_SRCS
Expand Down Expand Up @@ -260,11 +263,16 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux"
dl
m
)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND SQLITE3MC_LINK_LIBRARIES "-framework Security")
endif()
set(SHARED_LIB_EXPORT_DEFINITION "__attribute__((visibility(\"default\")))")
else()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2 -maes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 -maes")
endif()
set(SHARED_LIB_EXPORT_DEFINITION "__declspec(dllexport)")
endif()

set(_LIB_DIFINITIONS
Expand All @@ -280,14 +288,15 @@ set(_DEFAULT_DEFINITIONS
UNICODE
)

set(SQLITE3MC_TARGET "sqlite3mc")
set(SQLITE3MC_SHELL_TARGET "sqlite3mc_shell")

set(SQLITE3MC_LINK "SHARED")

if(SQLITE3MC_STATIC)
set(SQLITE3MC_LINK "STATIC")
set(SQLITE3MC_TARGET "sqlite3mc_static")
else()
set(SQLITE3MC_LINK "SHARED")
set(SQLITE3MC_TARGET "sqlite3mc")
list(APPEND SQLITE3MC_BASE_SRCS ${SQLITE3MC_DLLRES_SRCS})
endif()

# Lib Project
Expand All @@ -308,6 +317,12 @@ target_link_libraries(${SQLITE3MC_TARGET} PRIVATE
${SQLITE3MC_LINK_LIBRARIES}
)

if(NOT SQLITE3MC_STATIC)
target_compile_definitions(${SQLITE3MC_TARGET} PRIVATE
SQLITE_API=${SHARED_LIB_EXPORT_DEFINITION}
)
endif()

if(ZLIB_FOUND)
target_include_directories(${SQLITE3MC_TARGET} PRIVATE
${ZLIB_INCLUDE_DIRS}
Expand Down Expand Up @@ -337,6 +352,14 @@ if(SQLITE3MC_STATIC_RUNTIME_LINK)
endif()
message("Will build ${SQLITE3MC_TARGET} as ${SQLITE3MC_LINK}")

set_target_properties(${SQLITE3MC_TARGET} PROPERTIES PUBLIC_HEADER "${SQLITE3MC_PUBLIC_HEADERS}")
INSTALL(TARGETS ${SQLITE3MC_TARGET}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/${CMAKE_PROJECT_NAME}
RUNTIME DESTINATION bin
)

# Shell Executable project
if(SQLITE3MC_BUILD_SHELL)
add_executable(${SQLITE3MC_SHELL_TARGET}
Expand Down Expand Up @@ -381,4 +404,11 @@ if(SQLITE3MC_BUILD_SHELL)
_Enable_MT(${SQLIT3MC_SHELL_TARGET})
endif()
message("Will build ${SQLITE3MC_SHELL_TARGET}")

INSTALL(TARGETS ${SQLITE3MC_SHELL_TARGET}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/${CMAKE_PROJECT_NAME}
RUNTIME DESTINATION bin
)
endif()

0 comments on commit dce73ee

Please sign in to comment.