mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-29 15:19:44 +02:00
Allow building Tenacity without Conan
Conan can still be used, but it is fully optional. This should help packagers a lot. Signed-off-by: Edgar <Edgar@AnotherFoxGuy.com>
This commit is contained in:
parent
047729727a
commit
04609bba01
@ -137,6 +137,13 @@ else()
|
||||
message( STATUS "Could NOT find ccache nor sccache, no compiler caching enabled" )
|
||||
endif()
|
||||
|
||||
include( CMakeDependentOption )
|
||||
|
||||
# Test if conan is installed
|
||||
find_program(CONAN_CMD_TEST conan NO_CACHE)
|
||||
cmake_dependent_option(USE_CONAN "Build without conan" ON "NOT CONAN_CMD_TEST STREQUAL CONAN_CMD_TEST-NOTFOUND" OFF)
|
||||
message("Using conan: ${USE_CONAN}")
|
||||
|
||||
# Our very own project
|
||||
project( Tenacity )
|
||||
|
||||
@ -167,7 +174,6 @@ include( CheckIncludeFiles )
|
||||
include( CheckLibraryExists )
|
||||
include( CheckSymbolExists )
|
||||
include( CheckTypeSize )
|
||||
include( CMakeDependentOption )
|
||||
include( CMakeDetermineASM_NASMCompiler )
|
||||
include( CMakePushCheckState )
|
||||
include( GNUInstallDirs )
|
||||
|
@ -81,8 +81,8 @@ add_conan_lib(
|
||||
libmp3lame
|
||||
libmp3lame/3.100
|
||||
REQUIRED
|
||||
FIND_PACKAGE
|
||||
INTERFACE_NAME libmp3lame::libmp3lame
|
||||
PKG_CONFIG "lame >= 3.100"
|
||||
)
|
||||
|
||||
add_conan_lib(
|
||||
@ -109,12 +109,14 @@ else()
|
||||
set ( curl_ssl "openssl" )
|
||||
endif ()
|
||||
|
||||
add_conan_lib(
|
||||
ThreadPool
|
||||
threadpool/20140926
|
||||
REQUIRED
|
||||
ALWAYS_ALLOW_CONAN_FALLBACK
|
||||
)
|
||||
|
||||
# TODO: is threadpool still needed?
|
||||
# add_conan_lib(
|
||||
# ThreadPool
|
||||
# threadpool/20140926
|
||||
# REQUIRED
|
||||
# ALWAYS_ALLOW_CONAN_FALLBACK
|
||||
# )
|
||||
|
||||
add_conan_lib(
|
||||
RapidJSON
|
||||
|
@ -1,10 +1,12 @@
|
||||
# Load Conan
|
||||
include( conan )
|
||||
|
||||
conan_add_remote(NAME audacity
|
||||
URL https://artifactory.audacityteam.org/artifactory/api/conan/conan-local
|
||||
VERIFY_SSL True
|
||||
)
|
||||
if(USE_CONAN)
|
||||
conan_add_remote(NAME audacity
|
||||
URL https://artifactory.audacityteam.org/artifactory/api/conan/conan-local
|
||||
VERIFY_SSL True
|
||||
)
|
||||
endif()
|
||||
|
||||
set( CONAN_BUILD_REQUIRES )
|
||||
set( CONAN_REQUIRES )
|
||||
@ -21,6 +23,7 @@ set( CONAN_RESOLVE_LIST )
|
||||
# OPTION_NAME wxwidgets
|
||||
# SYMBOL WXWIDGET
|
||||
# REQUIRED
|
||||
# FIND_PACKAGE
|
||||
# ALWAYS_ALLOW_CONAN_FALLBACK
|
||||
# PKG_CONFIG "wxwidgets >= 3.1.3"
|
||||
# FIND_PACKAGE_OPTIONS COMPONENTS adv base core html qa xml
|
||||
@ -39,13 +42,18 @@ function (add_conan_lib package conan_package_name )
|
||||
set( current_var "conan_package_options" )
|
||||
|
||||
set( option_name_base ${package} )
|
||||
set( allow_find_package off )
|
||||
set( find_package_options )
|
||||
set( conan_package_options )
|
||||
set( required off )
|
||||
set( no_pkg off )
|
||||
set( pkg_config_options )
|
||||
set( system_only ${${_OPT}obey_system_dependencies})
|
||||
set( interface_name "${package}::${package}")
|
||||
if(USE_CONAN)
|
||||
set( allow_find_package off )
|
||||
else()
|
||||
set( allow_find_package on )
|
||||
endif()
|
||||
|
||||
# Parse function arguments
|
||||
|
||||
@ -54,6 +62,9 @@ function (add_conan_lib package conan_package_name )
|
||||
set( list_mode on )
|
||||
set( allow_find_package on )
|
||||
set( current_var "find_package_options" )
|
||||
elseif ( opt STREQUAL "FIND_PACKAGE" )
|
||||
set( list_mode on )
|
||||
set( allow_find_package on )
|
||||
elseif ( opt STREQUAL "CONAN_OPTIONS" )
|
||||
set( list_mode on )
|
||||
set( current_var "conan_package_options" )
|
||||
@ -93,7 +104,11 @@ function (add_conan_lib package conan_package_name )
|
||||
|
||||
set( option_desc "local" )
|
||||
|
||||
if( pkg_config_options OR allow_find_package )
|
||||
if(NOT USE_CONAN)
|
||||
set( sysopt "system" )
|
||||
set( default "system" )
|
||||
set( option_desc "system (forced), " )
|
||||
elseif( pkg_config_options OR allow_find_package )
|
||||
set( sysopt "system" )
|
||||
string( PREPEND option_desc "system (if available), " )
|
||||
set( default "${${_OPT}lib_preference}" )
|
||||
@ -129,12 +144,12 @@ function (add_conan_lib package conan_package_name )
|
||||
return()
|
||||
endif()
|
||||
|
||||
if( ${option_name} STREQUAL "system" )
|
||||
if( pkg_config_options )
|
||||
if( ${option_name} STREQUAL "system" OR NOT USE_CONAN)
|
||||
if( pkg_config_options AND NOT no_pkg )
|
||||
pkg_check_modules( PKG_${package} ${pkg_config_options} )
|
||||
|
||||
if( PKG_${package}_FOUND )
|
||||
message( STATUS "Using '${package}' system library" )
|
||||
message( STATUS "Using '${package}' system library (Found by pkg_config)" )
|
||||
|
||||
# Create the target interface library
|
||||
add_library( ${interface_name} INTERFACE IMPORTED GLOBAL)
|
||||
@ -152,15 +167,21 @@ function (add_conan_lib package conan_package_name )
|
||||
endif()
|
||||
|
||||
if( allow_find_package )
|
||||
find_package( ${package} QUIET ${find_package_options} )
|
||||
find_package( ${package} ${find_package_options} )
|
||||
|
||||
if ( ${package}_FOUND )
|
||||
message( STATUS "Using '${package}' system library" )
|
||||
message( STATUS "Using '${package}' system library (Found by find_package)" )
|
||||
|
||||
# wxwidgets needs to have vars in the global scope
|
||||
if("${package}" STREQUAL "wxWidgets")
|
||||
patch_wxwidgets_vars()
|
||||
endif()
|
||||
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if( system_only )
|
||||
if( system_only OR NOT USE_CONAN )
|
||||
message( FATAL_ERROR "Failed to find the system package ${package}" )
|
||||
else()
|
||||
set( ${option_name} "local" )
|
||||
@ -237,6 +258,7 @@ function ( _conan_install build_type )
|
||||
endfunction()
|
||||
|
||||
macro( resolve_conan_dependencies )
|
||||
if(USE_CONAN)
|
||||
message(STATUS
|
||||
"Executing Conan: \
|
||||
REQUIRES ${CONAN_REQUIRES}
|
||||
@ -266,6 +288,8 @@ macro( resolve_conan_dependencies )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endif(USE_CONAN)
|
||||
|
||||
file(GLOB dependency_helpers "${AUDACITY_MODULE_PATH}/dependencies/*.cmake")
|
||||
|
||||
foreach(f ${dependency_helpers})
|
||||
@ -284,3 +308,15 @@ macro ( find_required_package package_name system_package_name )
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro ( patch_wxwidgets_vars )
|
||||
message("patch_wxwidgets_vars")
|
||||
set(wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}" CACHE INTERNAL "wxWidgets_INCLUDE_DIRS")
|
||||
set(wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}" CACHE INTERNAL "wxWidgets_LIBRARIES")
|
||||
set(wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}" CACHE INTERNAL "wxWidgets_LIBRARY_DIRS")
|
||||
set(wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}" CACHE INTERNAL "wxWidgets_DEFINITIONS")
|
||||
set(wxWidgets_DEFINITIONS_GENERAL "${wxWidgets_DEFINITIONS_GENERAL}" CACHE INTERNAL "wxWidgets_DEFINITIONS_GENERAL")
|
||||
set(wxWidgets_DEFINITIONS_DEBUG "${wxWidgets_DEFINITIONS_DEBUG}" CACHE INTERNAL "wxWidgets_DEFINITIONS_DEBUG")
|
||||
set(wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}" CACHE INTERNAL "wxWidgets_CXX_FLAGS")
|
||||
set(wxWidgets_USE_FILE "${wxWidgets_USE_FILE}" CACHE INTERNAL "wxWidgets_DEFINITIONS_DEBUG")
|
||||
endmacro()
|
76
cmake-proxies/cmake-modules/Findlibmp3lame.cmake
Normal file
76
cmake-proxies/cmake-modules/Findlibmp3lame.cmake
Normal file
@ -0,0 +1,76 @@
|
||||
# This file is part of Mixxx, Digital DJ'ing software.
|
||||
# Copyright (C) 2001-2020 Mixxx Development Team
|
||||
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
|
||||
# later version. See the LICENSE file for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
Findlibmp3lame
|
||||
-----------
|
||||
|
||||
Finds the LAME library.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module provides the following imported targets, if found:
|
||||
|
||||
``libmp3lame::libmp3lame``
|
||||
The LAME library
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``libmp3lame_FOUND``
|
||||
True if the system has the LAME library.
|
||||
``libmp3lame_INCLUDE_DIRS``
|
||||
Include directories needed to use LAME.
|
||||
``libmp3lame_LIBRARIES``
|
||||
Libraries needed to link to LAME.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``libmp3lame_INCLUDE_DIR``
|
||||
The directory containing ``lame/lame.h``.
|
||||
``libmp3lame_LIBRARY``
|
||||
The path to the LAME library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_path(libmp3lame_INCLUDE_DIR
|
||||
NAMES lame/lame.h
|
||||
DOC "LAME include directory")
|
||||
mark_as_advanced(libmp3lame_INCLUDE_DIR)
|
||||
|
||||
find_library(libmp3lame_LIBRARY
|
||||
NAMES mp3lame mp3lame-static
|
||||
DOC "LAME library"
|
||||
)
|
||||
mark_as_advanced(libmp3lame_LIBRARY)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
libmp3lame
|
||||
DEFAULT_MSG
|
||||
libmp3lame_LIBRARY
|
||||
libmp3lame_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(libmp3lame_FOUND)
|
||||
set(libmp3lame_LIBRARIES "${libmp3lame_LIBRARY}")
|
||||
set(libmp3lame_INCLUDE_DIRS "${libmp3lame_INCLUDE_DIR}")
|
||||
|
||||
if(NOT TARGET libmp3lame::libmp3lame)
|
||||
add_library(libmp3lame::libmp3lame INTERFACE IMPORTED GLOBAL)
|
||||
set_target_properties(libmp3lame::libmp3lame
|
||||
PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${libmp3lame_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${libmp3lame_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
message("Found libmp3lame: ${libmp3lame_INCLUDE_DIRS} | ${libmp3lame_LIBRARIES}")
|
||||
endif()
|
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ if( ${_OPT}use_wxwidgets STREQUAL "system" )
|
||||
endif()
|
||||
|
||||
target_compile_definitions( wxwidgets::wxwidgets INTERFACE
|
||||
${wxWidgets_DEFINITIONS_GENERAL}
|
||||
${wxWidgets_DEFINITIONS_GENERAL} ${wxWidgets_DEFINITIONS}
|
||||
$<$<CONFIG:Debug>:
|
||||
${wxWidgets_DEFINITIONS_DEBUG}
|
||||
>
|
||||
|
@ -1,5 +1,3 @@
|
||||
include( CMakeDependentOption )
|
||||
|
||||
set( TARGET manual )
|
||||
set( TARGET_ROOT ${topdir}/manual )
|
||||
|
||||
|
20
lib-src/ThreadPool/COPYING
Normal file
20
lib-src/ThreadPool/COPYING
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2012 Jakob Progsch, Václav Zeman
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
17
lib-src/ThreadPool/README.md
Normal file
17
lib-src/ThreadPool/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
ThreadPool
|
||||
==========
|
||||
|
||||
A simple C++11 Thread Pool implementation.
|
||||
|
||||
Basic usage:
|
||||
```c++
|
||||
// create thread pool with 4 worker threads
|
||||
ThreadPool pool(4);
|
||||
|
||||
// enqueue and store future
|
||||
auto result = pool.enqueue([](int answer) { return answer; }, 42);
|
||||
|
||||
// get result from future
|
||||
std::cout << result.get() << std::endl;
|
||||
|
||||
```
|
98
lib-src/ThreadPool/ThreadPool.h
Normal file
98
lib-src/ThreadPool/ThreadPool.h
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef THREAD_POOL_H
|
||||
#define THREAD_POOL_H
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <future>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
|
||||
class ThreadPool {
|
||||
public:
|
||||
ThreadPool(size_t);
|
||||
template<class F, class... Args>
|
||||
auto enqueue(F&& f, Args&&... args)
|
||||
-> std::future<typename std::result_of<F(Args...)>::type>;
|
||||
~ThreadPool();
|
||||
private:
|
||||
// need to keep track of threads so we can join them
|
||||
std::vector< std::thread > workers;
|
||||
// the task queue
|
||||
std::queue< std::function<void()> > tasks;
|
||||
|
||||
// synchronization
|
||||
std::mutex queue_mutex;
|
||||
std::condition_variable condition;
|
||||
bool stop;
|
||||
};
|
||||
|
||||
// the constructor just launches some amount of workers
|
||||
inline ThreadPool::ThreadPool(size_t threads)
|
||||
: stop(false)
|
||||
{
|
||||
for(size_t i = 0;i<threads;++i)
|
||||
workers.emplace_back(
|
||||
[this]
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
std::function<void()> task;
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(this->queue_mutex);
|
||||
this->condition.wait(lock,
|
||||
[this]{ return this->stop || !this->tasks.empty(); });
|
||||
if(this->stop && this->tasks.empty())
|
||||
return;
|
||||
task = std::move(this->tasks.front());
|
||||
this->tasks.pop();
|
||||
}
|
||||
|
||||
task();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// add new work item to the pool
|
||||
template<class F, class... Args>
|
||||
auto ThreadPool::enqueue(F&& f, Args&&... args)
|
||||
-> std::future<typename std::result_of<F(Args...)>::type>
|
||||
{
|
||||
using return_type = typename std::result_of<F(Args...)>::type;
|
||||
|
||||
auto task = std::make_shared< std::packaged_task<return_type()> >(
|
||||
std::bind(std::forward<F>(f), std::forward<Args>(args)...)
|
||||
);
|
||||
|
||||
std::future<return_type> res = task->get_future();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(queue_mutex);
|
||||
|
||||
// don't allow enqueueing after stopping the pool
|
||||
if(stop)
|
||||
throw std::runtime_error("enqueue on stopped ThreadPool");
|
||||
|
||||
tasks.emplace([task](){ (*task)(); });
|
||||
}
|
||||
condition.notify_one();
|
||||
return res;
|
||||
}
|
||||
|
||||
// the destructor joins all threads
|
||||
inline ThreadPool::~ThreadPool()
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(queue_mutex);
|
||||
stop = true;
|
||||
}
|
||||
condition.notify_all();
|
||||
for(std::thread &worker: workers)
|
||||
worker.join();
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user