From 35d5ba4eff0421e10aeedecabe382a1d01e21849 Mon Sep 17 00:00:00 2001 From: Festus Hagen Date: Wed, 20 May 2015 03:06:03 -0400 Subject: [PATCH] Add BUILD_BINDINGS option, moved if(BUILD_EXAMPLES) to taglib/CMakeLists, plus some cleanup. --- .travis.yml | 2 +- CMakeLists.txt | 52 +++++++++++++++++++++++------------------ examples/CMakeLists.txt | 51 ++++++++++++++++------------------------ 3 files changed, 50 insertions(+), 55 deletions(-) diff --git a/.travis.yml b/.travis.yml index b526e274..c5ec8862 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,5 @@ addons: packages: - libcppunit-dev - zlib1g-dev -script: cmake -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON . && make && make check +script: cmake -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BINDINGS=ON . && make && make check diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bde0d0a..a5e9bb9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,24 +8,25 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -option(ENABLE_STATIC "Make static version of libtag" OFF) +option(ENABLE_STATIC "Make static version of libtag" OFF) if(ENABLE_STATIC) add_definitions(-DTAGLIB_STATIC) set(BUILD_SHARED_LIBS OFF) else() set(BUILD_SHARED_LIBS ON) endif() -OPTION(ENABLE_STATIC_RUNTIME "Visual Studio, link with runtime statically" OFF) +option(ENABLE_STATIC_RUNTIME "Visual Studio, link with runtime statically" OFF) -option(VISIBILITY_HIDDEN "Build with -fvisibility=hidden" OFF) +option(VISIBILITY_HIDDEN "Build with -fvisibility=hidden" OFF) if(VISIBILITY_HIDDEN) - add_definitions (-fvisibility=hidden) + add_definitions(-fvisibility=hidden) endif() -option(BUILD_TESTS "Build the test suite" OFF) -option(BUILD_EXAMPLES "Build the examples" OFF) +option(BUILD_TESTS "Build the test suite" OFF) +option(BUILD_EXAMPLES "Build the examples" OFF) +option(BUILD_BINDINGS "Build the bindings" ON) -option(NO_ITUNES_HACKS "Disable workarounds for iTunes bugs" OFF) +option(NO_ITUNES_HACKS "Disable workarounds for iTunes bugs" OFF) add_definitions(-DHAVE_CONFIG_H) set(TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/") @@ -38,14 +39,15 @@ set(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The su set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The subdirectory to the header prefix" FORCE) if(APPLE) - option(BUILD_FRAMEWORK "Build an OS X framework" OFF) - set(FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to.") + option(BUILD_FRAMEWORK "Build an OS X framework" OFF) + set(FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to.") endif() if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") endif() + if (MSVC AND ENABLE_STATIC_RUNTIME) foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") @@ -61,7 +63,7 @@ set(TAGLIB_LIB_VERSION_STRING "${TAGLIB_LIB_MAJOR_VERSION}.${TAGLIB_LIB_MINOR_VE # 1. If the library source code has changed at all since the last update, then increment revision. # 2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. # 3. If any interfaces have been added since the last public release, then increment age. -# 4. If any interfaces have been removed since the last public release, then set age to 0. +# 4. If any interfaces have been removed since the last public release, then set age to 0. set(TAGLIB_SOVERSION_CURRENT 16) set(TAGLIB_SOVERSION_REVISION 0) set(TAGLIB_SOVERSION_AGE 15) @@ -109,25 +111,29 @@ endif() configure_file(taglib/taglib_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h") -add_subdirectory(taglib) -add_subdirectory(bindings) +add_subdirectory(taglib) + +if(BUILD_BINDINGS) + add_subdirectory(bindings) +endif() + if(BUILD_TESTS) - enable_testing() - add_subdirectory(tests) -endif(BUILD_TESTS) -add_subdirectory(examples) + enable_testing() + add_subdirectory(tests) +endif() + +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile") file(COPY doc/taglib.png DESTINATION doc) add_custom_target(docs doxygen) # uninstall target -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) if (NOT TARGET uninstall) - add_custom_target(uninstall - COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") -endif() \ No newline at end of file + add_custom_target(uninstall COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") +endif() + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 17d4bd6b..7792a2a6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,50 +1,39 @@ -if(BUILD_EXAMPLES) -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../taglib - ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/toolkit - ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ape - ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg - ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v1 - ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2 - ${CMAKE_CURRENT_SOURCE_DIR}/../bindings/c/ ) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/toolkit + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ape + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v1 + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2 + ${CMAKE_CURRENT_SOURCE_DIR}/../bindings/c/ +) if(ENABLE_STATIC) - add_definitions(-DTAGLIB_STATIC) + add_definitions(-DTAGLIB_STATIC) endif(ENABLE_STATIC) ########### next target ############### -ADD_EXECUTABLE(tagreader tagreader.cpp) - -TARGET_LINK_LIBRARIES(tagreader tag ) - +add_executable(tagreader tagreader.cpp) +target_link_libraries(tagreader tag) ########### next target ############### -ADD_EXECUTABLE(tagreader_c tagreader_c.c) - -TARGET_LINK_LIBRARIES(tagreader_c tag_c ) - +add_executable(tagreader_c tagreader_c.c) +target_link_libraries(tagreader_c tag_c) ########### next target ############### -ADD_EXECUTABLE(tagwriter tagwriter.cpp) - -TARGET_LINK_LIBRARIES(tagwriter tag ) - +add_executable(tagwriter tagwriter.cpp) +target_link_libraries(tagwriter tag) ########### next target ############### -ADD_EXECUTABLE(framelist framelist.cpp) - -TARGET_LINK_LIBRARIES(framelist tag ) - +add_executable(framelist framelist.cpp) +target_link_libraries(framelist tag) ########### next target ############### -ADD_EXECUTABLE(strip-id3v1 strip-id3v1.cpp) - -TARGET_LINK_LIBRARIES(strip-id3v1 tag ) - - -endif(BUILD_EXAMPLES) +add_executable(strip-id3v1 strip-id3v1.cpp) +target_link_libraries(strip-id3v1 tag)