Skip to content

Commit

Permalink
Projucer: Try linking with JUCE helper targets (#119)
Browse files Browse the repository at this point in the history
* Projucer: Try linking with JUCE helper targets

* Fix typo

* Watch out: linuxPackages and linuxLibs are handled differently!

* Add flags recommended by Robbert

* Trying to fix linker flags

---------

Co-authored-by: jatinchowdhury18 <[email protected]>
  • Loading branch information
jatinchowdhury18 and jatinchowdhury18 authored Nov 20, 2023
1 parent 9ed8659 commit 54d83e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ set(CMAKE_CXX_STANDARD 17)
# Make sure to set the same MacOS deployment target as you have set in the Projucer
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment target")
# If you want to build a universal binary on Mac by default, you may want to include this line
# set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
# If the Projucer is using "static runtime" for Visual Studio:
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "Runtime")
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>:Release>" CACHE STRING "Runtime")
Expand Down
19 changes: 11 additions & 8 deletions cmake/JucerClap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,16 @@ function(create_jucer_clap_target)
endif()

elseif(UNIX)
# Compiler and linker flags recommended by Robbert:
set_target_properties(${clap_target} PROPERTIES
VISIBILITY_INLINES_HIDDEN TRUE
C_VISBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")

# Base Linux deps: all JUCE apps need these:
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${clap_target} PUBLIC Threads::Threads rt dl)
target_link_libraries(${clap_target} PUBLIC rt dl pthread)

# Link other deps depending on which JUCE modules are in use:
execute_process(
Expand All @@ -182,14 +188,11 @@ function(create_jucer_clap_target)
OUTPUT_VARIABLE juce_module_paths
)

# Deps are copied from the linuxPackages and linuxLibs field in each module header... eventually we should get those programmatically (@TODO)
if(juce_module_paths MATCHES "juce_audio_devices")
find_package(ALSA REQUIRED)
target_link_libraries(${clap_target} PUBLIC ALSA::ALSA ${ALSA_LIBRARIES})
target_link_libraries(${clap_target} PUBLIC juce::pkgconfig_juce_audio_devices_LINUX_DEPS)
endif()
if(juce_module_paths MATCHES "juce_graphics")
find_package(Freetype REQUIRED)
target_link_libraries(${clap_target} PUBLIC Freetype::Freetype)
target_link_libraries(${clap_target} PUBLIC juce::pkgconfig_juce_graphics_LINUX_DEPS)
endif()
if(juce_module_paths MATCHES "juce_opengl")
target_link_libraries(${clap_target} PUBLIC GL)
Expand Down

0 comments on commit 54d83e1

Please sign in to comment.