Commit 573dbc12 authored by Vitaliy Kirsanov's avatar Vitaliy Kirsanov Committed by Erik de Castro Lopo

Use of BUILD_SHARED_LIBS added

parent 1cb968a7
......@@ -14,10 +14,7 @@ endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline")
if(CMAKE_BULD_TYPE STREQUAL Release)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -funroll-loops")
endif()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -funroll-loops")
option(ENABLE_SSP "Enable GNU GCC stack smash protection" OFF)
endif()
......
......@@ -9,31 +9,18 @@ find_library(OGG_LIBRARY
NAMES ogg libogg
HINTS ${_OGG_LIBRARY_DIRS})
find_library(OGG_LIBRARY_STATIC
NAMES libogg.a libogg_static
HINTS ${_OGG_LIBRARY_DIRS})
mark_as_advanced(
OGG_INCLUDE_DIR
OGG_LIBRARY
OGG_LIBRARY_DIRS)
OGG_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OGG
REQUIRED_VARS OGG_INCLUDE_DIR OGG_LIBRARY
VERSION_VAR _OGG_VERSION)
if(OGG_FOUND)
if(NOT Ogg::Ogg)
add_library(Ogg::Ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::Ogg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIR}"
IMPORTED_LOCATION "${OGG_LIBRARY}")
endif()
if(NOT Ogg::Ogg-static AND _OGG_LIBRARY_STATIC)
add_library(Ogg::Ogg-static STATIC IMPORTED)
set_target_properties(Ogg::Ogg-static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIR}"
IMPORTED_LOCATION "${OGG_LIBRARY_STATIC}")
endif()
if(OGG_FOUND AND NOT TARGET Ogg::Ogg)
add_library(Ogg::Ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::Ogg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIR}"
IMPORTED_LOCATION "${OGG_LIBRARY}")
endif()
......@@ -64,7 +64,6 @@ check_c_source_compiles("
add_definitions(
-D_DARWIN_C_SOURCE
-D_POSIX_PTHREAD_SEMANTICS
-D__STDC_WANT_IEC_60559_ATTRIBS_EXT__
-D__STDC_WANT_IEC_60559_BFP_EXT__
-D__STDC_WANT_IEC_60559_DFP_EXT__
-D__STDC_WANT_IEC_60559_FUNCS_EXT__
......
......@@ -199,9 +199,6 @@
#endif
/* Version number of package */
#cmakedefine VERSION
/* Target processor is big endian. */
#define WORDS_BIGENDIAN CPU_IS_BIG_ENDIAN
......@@ -211,10 +208,14 @@
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#cmakedefine _FILE_OFFSET_BITS
#ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
#endif
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
#cmakedefine _LARGEFILE_SOURCE
#ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE
#endif
/* Define for large files, on AIX-style hosts. */
#cmakedefine _LARGE_FILES
......@@ -229,11 +230,5 @@
/* Define to 1 if you need to in order for `stat' and other things to work. */
#cmakedefine _POSIX_SOURCE
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#cmakedefine inline
#endif
/* Define to __typeof__ if your compiler spells it that way. */
#cmakedefine typeof
add_executable(decode_file main.c)
target_link_libraries(decode_file FLAC-static)
target_link_libraries(decode_file FLAC)
add_executable(encode_file main.c)
target_link_libraries(encode_file FLAC-static)
target_link_libraries(encode_file FLAC)
add_executable(decode_file_cxx main.cpp)
target_link_libraries(decode_file_cxx FLAC++-static)
target_link_libraries(decode_file_cxx FLAC++)
add_executable(encode_file_cxx main.cpp)
target_link_libraries(encode_file_cxx FLAC++-static)
target_link_libraries(encode_file_cxx FLAC++)
......@@ -11,7 +11,7 @@ endif()
add_executable(benchmark_residual benchmark_residual.c util.c)
target_include_directories(benchmark_residual PRIVATE
"$<TARGET_PROPERTY:FLAC-static,SOURCE_DIR>/include")
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/include")
target_link_libraries(benchmark_residual
FLAC-static
FLAC
$<$<BOOL:${HAVE_CLOCK_GETTIME}>:rt>)
......@@ -11,7 +11,7 @@ add_executable(flac
utils.c
vorbiscomment.c)
target_link_libraries(flac
FLAC-static
FLAC
getopt
replaygain_synthesis
utf8)
......
......@@ -18,30 +18,26 @@ check_cxx_source_compiles("
#endif"
HAVE_CXX_VARARRAYS)
set(SOURCES
add_library(FLAC++
metadata.cpp
stream_decoder.cpp
stream_encoder.cpp)
add_library(FLAC++-static STATIC ${SOURCES})
target_compile_definitions(FLAC++-static PUBLIC FLAC__NO_DLL)
target_include_directories(FLAC++-static INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(FLAC++-static PUBLIC FLAC-static)
add_library(FLAC++ SHARED ${SOURCES})
target_compile_definitions(FLAC++ PRIVATE FLACPP_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
target_compile_definitions(FLAC++
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLACPP_API_EXPORTS>
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>
PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:FLAC__NO_DLL>)
target_include_directories(FLAC++ INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(FLAC++ PRIVATE FLAC)
set_target_properties(FLAC++ PROPERTIES
CXX_VISIBILITY_PRESET hidden
VERSION 6.3.0
SOVERSION 6)
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(FLAC++ PUBLIC FLAC)
if(BUILD_SHARED_LIBS)
set_target_properties(FLAC++ PROPERTIES
CXX_VISIBILITY_PRESET hidden
VERSION 6.3.0
SOVERSION 6)
endif()
install(TARGETS FLAC++ FLAC++-static EXPORT targets
install(TARGETS FLAC++ EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
......
......@@ -54,7 +54,9 @@ set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
configure_file(flac.pc.in flac.pc @ONLY)
set(SOURCES
include_directories("include")
add_library(FLAC
bitmath.c
bitreader.c
bitwriter.c
......@@ -88,38 +90,28 @@ set(SOURCES
$<$<BOOL:${OGG_FOUND}>:ogg_mapping.c>
$<$<BOOL:${WIN32}>:windows_unicode_filenames.c>)
if(TARGET FLAC-asm)
list(APPEND SOURCES $<TARGET_OBJECTS:FLAC-asm>)
endif()
include_directories("include")
add_library(FLAC-static STATIC ${SOURCES})
target_compile_definitions(FLAC-static PUBLIC FLAC__NO_DLL)
target_include_directories(FLAC-static INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(FLAC-static PUBLIC $<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET Ogg::Ogg-static)
target_link_libraries(FLAC-static PUBLIC Ogg::Ogg-static)
elseif(TARGET Ogg::Ogg)
target_link_libraries(FLAC-static PUBLIC Ogg::Ogg)
target_sources(FLAC PRIVATE $<TARGET_OBJECTS:FLAC-asm>)
endif()
add_library(FLAC SHARED ${SOURCES})
target_compile_definitions(FLAC PRIVATE FLAC_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
target_compile_definitions(FLAC
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC_API_EXPORTS>
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>
PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:FLAC__NO_DLL>)
target_include_directories(FLAC INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(FLAC PRIVATE $<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET Ogg::Ogg)
target_link_libraries(FLAC PUBLIC Ogg::Ogg)
endif()
set_target_properties(FLAC PROPERTIES
C_VISIBILITY_PRESET hidden
VERSION 8.3.0
SOVERSION 8)
if(BUILD_SHARED_LIBS)
set_target_properties(FLAC PROPERTIES
C_VISIBILITY_PRESET hidden
VERSION 8.3.0
SOVERSION 8)
endif()
install(TARGETS FLAC FLAC-static EXPORT targets
install(TARGETS FLAC EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
......
......@@ -9,7 +9,7 @@ add_executable(metaflac
options.c
usage.c
utils.c)
target_link_libraries(metaflac FLAC-static getopt utf8)
target_link_libraries(metaflac FLAC getopt utf8)
if(TARGET win_utf8_io)
target_link_libraries(metaflac win_utf8_io)
endif()
......
......@@ -7,7 +7,7 @@ add_library(grabbag STATIC
seektable.c
snprintf.c)
target_link_libraries(grabbag PUBLIC
FLAC-static
FLAC
replaygain_analysis)
if(TARGET win_utf8_io)
target_link_libraries(grabbag PUBLIC win_utf8_io)
......
add_executable(test_cuesheet main.c)
target_link_libraries(test_cuesheet FLAC-static grabbag)
target_link_libraries(test_cuesheet FLAC grabbag)
add_executable(test_picture main.c)
target_link_libraries(test_picture FLAC-static grabbag)
target_link_libraries(test_picture FLAC grabbag)
......@@ -5,4 +5,4 @@ add_executable(test_libFLAC++
metadata.cpp
metadata_manip.cpp
metadata_object.cpp)
target_link_libraries(test_libFLAC++ FLAC++-static test_libs_common grabbag)
target_link_libraries(test_libFLAC++ FLAC++ test_libs_common grabbag)
......@@ -10,9 +10,14 @@ add_executable(test_libFLAC
metadata.c
metadata_manip.c
metadata_object.c
md5.c)
md5.c
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/bitreader.c"
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/bitwriter.c"
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/crc.c"
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/md5.c")
target_compile_definitions(test_libFLAC PRIVATE
$<$<BOOL:${ENABLE_64_BIT_WORDS}>:ENABLE_64_BIT_WORDS>)
target_include_directories(test_libFLAC PRIVATE "$<TARGET_PROPERTY:FLAC-static,SOURCE_DIR>/include")
target_link_libraries(test_libFLAC FLAC-static grabbag test_libs_common)
target_include_directories(test_libFLAC PRIVATE
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/include")
target_link_libraries(test_libFLAC FLAC grabbag test_libs_common)
add_library(test_libs_common STATIC
file_utils_flac.c
metadata_utils.c)
target_link_libraries(test_libs_common PUBLIC FLAC-static)
target_link_libraries(test_libs_common PUBLIC FLAC)
add_executable(test_seeking main.c)
target_link_libraries(test_seeking FLAC-static)
target_link_libraries(test_seeking FLAC)
add_executable(test_streams main.c)
target_link_libraries(test_streams FLAC-static grabbag)
target_link_libraries(test_streams FLAC grabbag)
add_executable(flacdiff main.cpp)
target_link_libraries(flacdiff FLAC++-static)
target_link_libraries(flacdiff FLAC++)
if(TARGET win_utf8_io)
target_link_libraries(flacdiff win_utf8_io)
endif()
add_executable(flactimer main.cpp)
target_link_libraries(flactimer FLAC++-static)
target_link_libraries(flactimer FLAC++)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment