From 20137386220fa120a5dd303b9d75f2031035830c Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Mon, 27 Dec 2021 20:55:45 +0100 Subject: [PATCH] [CMake] Add options for better MS Visual Studio building --- CMakeLists.txt | 7 +++++-- cmake/FindOgg.cmake | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73c7c6be..be6dd678 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") option(BUILD_CXXLIBS "Build libFLAC++" ON) option(BUILD_PROGRAMS "Build and install programs" ON) option(BUILD_EXAMPLES "Build and install examples" ON) +option(BUILD_TESTING "Build tests" ON) option(BUILD_DOCS "Build and install doxygen documents" ON) option(WITH_STACK_PROTECTOR "Enable GNU GCC stack smash protection" ON) option(INSTALL_MANPAGES "Install MAN pages" ON) @@ -39,10 +40,11 @@ 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(MSVC) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2 /Ob2 /Oi /Ot /Oy /MT") +endif() include(CMakePackageConfigHelpers) -include(CPack) -include(CTest) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckSymbolExists) @@ -53,6 +55,7 @@ include(CheckCXXSourceCompiles) include(GNUInstallDirs) include(UseSystemExtensions) include(TestBigEndian) +enable_testing() check_include_file("byteswap.h" HAVE_BYTESWAP_H) check_include_file("inttypes.h" HAVE_INTTYPES_H) diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake index b60c3526..34407fd4 100644 --- a/cmake/FindOgg.cmake +++ b/cmake/FindOgg.cmake @@ -1,13 +1,17 @@ find_package(PkgConfig) pkg_check_modules(_OGG QUIET ogg) +file(GLOB _OGG_DIR ../libogg-*) + find_path(OGG_INCLUDE_DIR NAMES "ogg/ogg.h" - PATHS ${_OGG_INCLUDE_DIRS}) + PATHS ${_OGG_INCLUDE_DIRS} + HINTS "${_OGG_DIR}/include") find_library(OGG_LIBRARY NAMES ogg libogg - HINTS ${_OGG_LIBRARY_DIRS}) + HINTS ${_OGG_LIBRARY_DIRS} + HINTS "${_OGG_DIR}/Release") mark_as_advanced( OGG_INCLUDE_DIR