Skip to content

Commit

Permalink
embed lib into toolset
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Jul 19, 2024
1 parent 4c1c154 commit 792efa0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.16)

set(CMAKE_CXX_STANDARD 23)
project(InsomniaToolset)
Expand All @@ -7,7 +7,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-ignored-qualifiers")

option(CLI "" ON)
option(GLTF "" ON)
set(EXPOSE_SYMBOLS spike;pugixml;gltf)
set(EXPOSE_SYMBOLS spike;pugixml;gltf;insomnia)

set(TPD_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rd_party)

Expand All @@ -18,6 +18,7 @@ toolset_version()
set_target_properties(spike_cli PROPERTIES OUTPUT_NAME insomnia_toolset)

add_subdirectory(common)
target_link_libraries(spike_cli insomnia-objects)
add_spike_subdir(extract)
add_spike_subdir(effect)

Expand Down
56 changes: 34 additions & 22 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
project(InsomniaLib VERSION 1)

build_target(
NAME
insomnia
TYPE
SHARED
SOURCES
src/serialize.cpp
src/reflected.cpp
LINKS
spike-interface
pugixml-interface
NO_VERINFO
NO_PROJECT_H)
add_library(insomnia-interface INTERFACE)
target_include_directories(insomnia-interface INTERFACE include)
target_link_libraries(insomnia-interface INTERFACE spike-interface pugixml-interface)
set(CORE_SOURCE_FILES src/serialize.cpp;src/reflected.cpp)

target_compile_definitions(
insomnia
PRIVATE IS_EXPORT REF_EXPORT
INTERFACE IS_IMPORT)
if(NOT NO_OBJECTS)
add_library(insomnia-objects OBJECT ${CORE_SOURCE_FILES})
target_link_libraries(insomnia-objects PUBLIC insomnia-interface)
set_target_properties(insomnia-objects PROPERTIES POSITION_INDEPENDENT_CODE
${OBJECTS_PID})
target_compile_options(insomnia-objects PRIVATE -fvisibility=hidden)

target_include_directories(insomnia PUBLIC include)
target_expose_defs(insomnia IS_EXPORT IS_IMPORT)
endif()

install(
TARGETS insomnia
LIBRARY NAMELINK_SKIP DESTINATION $<IF:$<BOOL:${MINGW}>,bin,lib>
RUNTIME DESTINATION bin)
if(BUILD_SHARED_LIBS)
add_library(insomnia SHARED ${CORE_SOURCE_FILES})
target_link_libraries(insomnia insomnia-interface spike pugixml)
target_compile_definitions(
insomnia
INTERFACE IS_IMPORT
PRIVATE IS_EXPORT)

if(WIN32 OR MINGW)
set_target_properties(
insomnia PROPERTIES SUFFIX ${PROJECT_VERSION_MAJOR}.dll PREFIX "")
else()
set_target_properties(
insomnia PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION
${PROJECT_VERSION_MAJOR})
endif()

install(
TARGETS insomnia
LIBRARY NAMELINK_SKIP DESTINATION $<IF:$<BOOL:${MINGW}>,bin,lib>
RUNTIME DESTINATION bin)
endif()
2 changes: 1 addition & 1 deletion effect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build_target(
extract_effect.cpp
INCLUDES
LINKS
insomnia
insomnia-interface
AUTHOR
"Lukas Cone"
DESCR
Expand Down
2 changes: 1 addition & 1 deletion extract/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build_target(
gltf.cpp
LINKS
gltf-interface
insomnia
insomnia-interface
AUTHOR
"Lukas Cone"
DESCR
Expand Down

0 comments on commit 792efa0

Please sign in to comment.