Commit e0b62a61 authored by evpobr's avatar evpobr Committed by Erik de Castro Lopo
Browse files

Bunch of CMake fixes

* Add more Git ignore patterns
* Fix Ogg dependency handling (closes #203)
* Remove unneeded compiler flag (closes #204)
* Fix Visual Studio DLL build error error C2491:
  'flac_internal_rename_utf8': definition of dllimport function not
  allowed (closes #205)
* Add alias targets
* Reduce number of CMake files
* Improve CMake intrinsics detection
parent 7a35c528
......@@ -77,3 +77,18 @@ test/picture.log
microbench/benchmark_residual
oss-fuzz/fuzz-decoder
oss-fuzz/fuzz-encoder
/*[Bb]uild*/
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
/.vs*/
......@@ -23,7 +23,7 @@ option(INSTALL_CMAKE_CONFIG_MODULE "Install CMake package-config module" ON)
option(WITH_OGG "ogg support (default: test for libogg)" ON)
if(WITH_OGG)
find_package(OGG REQUIRED)
find_package(Ogg REQUIRED)
endif()
find_package(Iconv)
......@@ -36,9 +36,6 @@ endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_EXE_LINKER_FLAGS -no-pie)
endif()
include(CMakePackageConfigHelpers)
include(CPack)
......@@ -57,7 +54,11 @@ include(TestBigEndian)
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
if(MSVC)
check_include_file("intrin.h" FLAC__HAS_X86INTRIN)
else()
check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
endif()
check_function_exists(fseeko HAVE_FSEEKO)
......@@ -140,7 +141,6 @@ if(INSTALL_CMAKE_CONFIG_MODULE)
FILES
"${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake"
"cmake/FindOGG.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
endif()
......
......@@ -41,7 +41,7 @@ EXTRA_DIST = \
CMakeLists.txt \
config.cmake.h.in \
flac-config.cmake.in \
cmake/FindOGG.cmake \
cmake/FindOgg.cmake \
cmake/UseSystemExtensions.cmake \
COPYING.FDL \
COPYING.GPL \
......
......@@ -14,7 +14,7 @@ mark_as_advanced(
OGG_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OGG
find_package_handle_standard_args(Ogg
REQUIRED_VARS OGG_INCLUDE_DIR OGG_LIBRARY
VERSION_VAR _OGG_VERSION)
......
......@@ -19,7 +19,28 @@ doxygen_add_docs(FLAC-doxygen
"${PROJECT_SOURCE_DIR}/include/FLAC"
"${PROJECT_SOURCE_DIR}/include/FLAC++")
add_subdirectory(html)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/api")
install(FILES
html/images/logo.svg
html/images/logo130.gif
html/changelog.html
html/developers.html
html/documentation.html
html/documentation_bugs.html
html/documentation_example_code.html
html/documentation_format_overview.html
html/documentation_tools.html
html/documentation_tools_flac.html
html/documentation_tools_metaflac.html
html/faq.html
html/favicon.ico
html/features.html
html/flac.css
html/format.html
html/id.html
html/index.html
html/license.html
html/ogg_mapping.html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html")
add_subdirectory(images)
install(FILES
changelog.html
developers.html
documentation.html
documentation_bugs.html
documentation_example_code.html
documentation_format_overview.html
documentation_tools.html
documentation_tools_flac.html
documentation_tools_metaflac.html
faq.html
favicon.ico
features.html
flac.css
format.html
id.html
index.html
license.html
ogg_mapping.html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html")
......@@ -38,7 +38,7 @@ html_DATA = \
license.html \
ogg_mapping.html
EXTRA_DIST = $(html_DATA) api CMakeLists.txt
EXTRA_DIST = $(html_DATA) api
if FLaC__HAS_DOXYGEN
# The install targets don't copy whole directories so we have to
......
install(FILES
logo.svg
logo130.gif
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/images")
......@@ -22,4 +22,4 @@ logos_DATA = \
logo.svg \
logo130.gif
EXTRA_DIST = $(logos_DATA) CMakeLists.txt
EXTRA_DIST = $(logos_DATA)
add_subdirectory("c")
add_subdirectory("c/decode/file")
add_subdirectory("c/encode/file")
if(BUILD_CXXLIBS)
add_subdirectory("cpp")
add_subdirectory("cpp/decode/file")
add_subdirectory("cpp/encode/file")
endif()
add_subdirectory("decode/file")
add_subdirectory("encode/file")
......@@ -17,5 +17,3 @@
# distribution.
SUBDIRS = decode encode
EXTRA_DIST = CMakeLists.txt
add_subdirectory("decode/file")
add_subdirectory("encode/file")
......@@ -17,5 +17,3 @@
# distribution.
SUBDIRS = decode encode
EXTRA_DIST = CMakeLists.txt
@PACKAGE_INIT@
if(@OGG_FOUND@)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
include(CMakeFindDependencyMacro)
find_dependency(OGG)
endif()
include(CMakeFindDependencyMacro)
find_dependency(Ogg)
include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake")
......
......@@ -7,12 +7,22 @@ add_subdirectory("libFLAC")
if(BUILD_CXXLIBS)
add_subdirectory("libFLAC++")
endif()
add_subdirectory("share")
add_subdirectory("share/replaygain_analysis")
add_subdirectory("share/replaygain_synthesis")
add_subdirectory("share/getopt")
add_subdirectory("share/utf8")
add_subdirectory("share/grabbag")
if(BUILD_PROGRAMS)
add_subdirectory("flac")
add_subdirectory("metaflac")
endif()
add_subdirectory("utils")
if(BUILD_CXXLIBS)
add_subdirectory(utils/flacdiff)
if(WIN32)
add_subdirectory(utils/flactimer)
endif()
endif()
if(WITH_XMMS)
add_subdirectory("plugin_common")
......
......@@ -9,16 +9,15 @@ add_executable(flacapp
main.c
local_string_utils.c
utils.c
vorbiscomment.c)
vorbiscomment.c
$<$<BOOL:${WIN32}>:../../include/share/win_utf8_io.h>
$<$<BOOL:${WIN32}>:../share/win_utf8_io/win_utf8_io.c>)
set_property(TARGET flacapp PROPERTY RUNTIME_OUTPUT_NAME flac)
target_link_libraries(flacapp
FLAC
getopt
replaygain_synthesis
utf8)
if(TARGET win_utf8_io)
target_link_libraries(flacapp win_utf8_io)
endif()
install(TARGETS flacapp EXPORT targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
......@@ -35,6 +35,8 @@ if(BUILD_SHARED_LIBS)
endif()
endif()
add_library(FLAC::FLAC++ ALIAS FLAC++)
install(TARGETS FLAC++ EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
......
......@@ -75,6 +75,8 @@ add_library(FLAC
stream_encoder_intrin_avx2.c
stream_encoder_framing.c
window.c
$<$<BOOL:${WIN32}>:../../include/share/windows_unicode_filenames.h>
$<$<BOOL:${WIN32}>:windows_unicode_filenames.c>
$<$<BOOL:${OGG_FOUND}>:ogg_decoder_aspect.c>
$<$<BOOL:${OGG_FOUND}>:ogg_encoder_aspect.c>
$<$<BOOL:${OGG_FOUND}>:ogg_helper.c>
......@@ -82,9 +84,6 @@ add_library(FLAC
if(TARGET FLAC-asm)
target_sources(FLAC PRIVATE $<TARGET_OBJECTS:FLAC-asm>)
endif()
if(WIN32)
target_sources(FLAC PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/windows_unicode_filenames.c>)
endif()
target_compile_definitions(FLAC
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC_API_EXPORTS>
......@@ -108,6 +107,8 @@ if(BUILD_SHARED_LIBS)
endif()
endif()
add_library(FLAC::FLAC ALIAS FLAC)
install(TARGETS FLAC EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
......
......@@ -8,11 +8,10 @@ add_executable(metaflac
operations_shorthand_vorbiscomment.c
options.c
usage.c
utils.c)
utils.c
$<$<BOOL:${WIN32}>:../../include/share/win_utf8_io.h>
$<$<BOOL:${WIN32}>:../share/win_utf8_io/win_utf8_io.c>)
target_link_libraries(metaflac FLAC getopt utf8)
if(TARGET win_utf8_io)
target_link_libraries(metaflac win_utf8_io)
endif()
install(TARGETS metaflac EXPORT targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
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