Corrected the CMakeLists to properly install the shared library
This commit is contained in:
parent
23f5da1b1d
commit
33a12be35a
6 changed files with 38 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,6 +4,7 @@ build-asan
|
|||
build-release
|
||||
build-reldeb
|
||||
build-debug
|
||||
docs
|
||||
.vscode
|
||||
perf.data
|
||||
perf.data.old
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14)
|
|||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
# Skip installing all dependencies
|
||||
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
|
||||
|
||||
# Enable LTO
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # To override the policy in abseil and benchmark
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ project(sfizz)
|
|||
###############################
|
||||
add_executable(sfzprint sfzprint.cpp)
|
||||
target_link_libraries(sfzprint sfizz::parser absl::flags_parse)
|
||||
install(TARGETS sfzprint DESTINATION . OPTIONAL)
|
||||
|
||||
###############################
|
||||
# Basic command line program
|
||||
|
|
@ -17,3 +18,4 @@ endif()
|
|||
|
||||
add_executable(sfizz_jack jack_client.cpp)
|
||||
target_link_libraries(sfizz_jack sfizz::sfizz jack absl::flags_parse)
|
||||
install(TARGETS sfizz_jack DESTINATION . OPTIONAL)
|
||||
|
|
|
|||
|
|
@ -65,17 +65,33 @@ target_include_directories(sfizz PUBLIC .)
|
|||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(sfizz PRIVATE Threads::Threads)
|
||||
if(UNIX)
|
||||
target_link_libraries(sfizz PUBLIC atomic)
|
||||
target_link_libraries(sfizz PUBLIC atomic)
|
||||
endif(UNIX)
|
||||
|
||||
target_link_libraries(sfizz PUBLIC absl::strings)
|
||||
target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map)
|
||||
|
||||
install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL)
|
||||
install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL)
|
||||
|
||||
add_library(sfizz::parser ALIAS sfizz_parser)
|
||||
add_library(sfizz::sfizz ALIAS sfizz)
|
||||
|
||||
add_library(sfizz_shared SHARED)
|
||||
set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz)
|
||||
set_target_properties(sfizz_shared PROPERTIES
|
||||
OUTPUT_NAME sfizz
|
||||
PUBLIC_HEADER sfizz.h)
|
||||
# set_target_properties(sfizz_shared PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_sources(sfizz_shared PRIVATE sfizz.cpp)
|
||||
target_link_libraries(sfizz_shared sfizz::sfizz)
|
||||
target_link_libraries(sfizz_shared sfizz::sfizz)
|
||||
configure_file(sfizz.pc.in sfizz.pc @ONLY)
|
||||
|
||||
if(UNIX)
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS sfizz_shared
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/sfizz/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
|
||||
endif()
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
|||
12
sfizz/sfizz.pc.in
Normal file
12
sfizz/sfizz.pc.in
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: @PROJECT_DESCRIPTION@
|
||||
Version: @PROJECT_VERSION@
|
||||
|
||||
Requires:
|
||||
Libs: -L${libdir} -lmylib
|
||||
Cflags: -I${includedir}
|
||||
Loading…
Add table
Reference in a new issue