Skip to content

Commit

Permalink
Build improvements (#221)
Browse files Browse the repository at this point in the history
* Added the USE_ALSA check, and allow cmake to continue without ALSA if library is not found

* Minor fix

* Snap doesn't work on the installer script, commented it out
  • Loading branch information
map588 authored Feb 11, 2025
1 parent 1e8752a commit 8e7aa0f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
28 changes: 19 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,20 @@ if (NOT CMAKE_BUILD_TYPE)
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# If the user does not specify NO_ALSA, check for the package, and THEN set the definition
# so the build doesn't fail.
if (NOT NO_ALSA)
find_package(ALSA REQUIRED)
add_definitions(-DUSE_ALSA)
find_package(ALSA)
if (ALSA_FOUND)
add_definitions(-DUSE_ALSA)
message(STATUS "Building the Clipboard Project with ALSA support.")
else()
message(STATUS "ALSA Library not found, building the Clipboard Project without ALSA support.")
endif()
else()
message(STATUS "Building the Clipboard Project without ALSA support.")
endif()

#find_path(LIBURING_INCLUDE_DIR liburing.h)
#if (LIBURING_INCLUDE_DIR)
# message(STATUS "Building the Clipboard Project with io_uring support")
Expand Down Expand Up @@ -96,14 +106,14 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${LIB_LOCATION})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BIN_LOCATION})

function(enable_lto this_target)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported)
if(lto_supported AND NOT NO_LTO)
set_property(TARGET ${this_target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=auto") # set the thread amount to what is available on the CPU
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported)
if(lto_supported AND NOT NO_LTO)
set_property(TARGET ${this_target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=auto") # set the thread amount to what is available on the CPU
endif()
endif()
endif()
endfunction()

add_subdirectory(src/gui)
Expand Down
14 changes: 7 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ then
fi

verify_flatpak
elif command -v snap > /dev/null 2>&1
then
if can_use_sudo
then
sudo snap install clipboard
verify
fi
# elif command -v snap > /dev/null 2>&1
# then
# if can_use_sudo
# then
# sudo snap install clipboard
# verify
# fi
elif command -v nix-env > /dev/null 2>&1
then
nix-env -iA nixpkgs.clipboard-jh
Expand Down
4 changes: 3 additions & 1 deletion src/cb/src/platforms/linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
#include "../clipboard.hpp"
#if defined(USE_ALSA)
#include <alsa/asoundlib.h>
#endif

void dummy_handler(const char* file, int line, const char* function, int err, const char* fmt, ...) {}

Expand Down Expand Up @@ -47,4 +49,4 @@ bool playAsyncSoundEffect(const std::valarray<short>& samples) {
#else
return false;
#endif
}
}

0 comments on commit 8e7aa0f

Please sign in to comment.