The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.0KB

  1. # ==============================================================================
  2. #
  3. # This file is part of the JUCE library.
  4. # Copyright (c) 2020 - Raw Material Software Limited
  5. #
  6. # JUCE is an open source library subject to commercial or open-source
  7. # licensing.
  8. #
  9. # By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  10. # Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  11. #
  12. # End User License Agreement: www.juce.com/juce-6-licence
  13. # Privacy Policy: www.juce.com/juce-privacy-policy
  14. #
  15. # Or: You may also use this code under the terms of the GPL v3 (see
  16. # www.gnu.org/licenses).
  17. #
  18. # JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  19. # EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  20. # DISCLAIMED.
  21. #
  22. # ==============================================================================
  23. function(_juce_create_atomic_target target_name)
  24. add_library("${target_name}" INTERFACE)
  25. add_library("juce::${target_name}" ALIAS "${target_name}")
  26. if(NOT ((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD")))
  27. return()
  28. endif()
  29. set(test_file_contents
  30. [[
  31. #include <atomic>
  32. int main (int argc, char** argv)
  33. {
  34. std::atomic<long long> ll { static_cast<long long> (argc) };
  35. ll ^= 1;
  36. return static_cast<int> (ll);
  37. }
  38. ]])
  39. string(RANDOM LENGTH 16 random_file_string)
  40. set(test_file_name "${CMAKE_CURRENT_BINARY_DIR}/check_atomic_${random_file_string}.cpp")
  41. string(RANDOM LENGTH 16 random_dir_string)
  42. set(test_bindir "${CMAKE_CURRENT_BINARY_DIR}/check_atomic_dir_${random_dir_string}")
  43. file(WRITE "${test_file_name}" "${test_file_contents}")
  44. try_compile(compile_result "${test_bindir}" "${test_file_name}"
  45. OUTPUT_VARIABLE test_build_output_0
  46. CXX_STANDARD 14
  47. CXX_STANDARD_REQUIRED TRUE
  48. CXX_EXTENSIONS FALSE)
  49. if(NOT compile_result)
  50. try_compile(compile_result "${test_bindir}" "${test_file_name}"
  51. OUTPUT_VARIABLE test_build_output_1
  52. LINK_LIBRARIES atomic
  53. CXX_STANDARD 14
  54. CXX_STANDARD_REQUIRED TRUE
  55. CXX_EXTENSIONS FALSE)
  56. if (NOT compile_result)
  57. message(FATAL_ERROR
  58. "First build output:\n"
  59. "${test_build_output_0}"
  60. "\n\nSecond build output:\n"
  61. "${test_build_output_1}"
  62. "\n\nJUCE requires support for std::atomic, but this system cannot "
  63. "successfully compile a program which uses std::atomic. "
  64. "You may need to install a dedicated libatomic package using your "
  65. "system's package manager.")
  66. endif()
  67. target_link_libraries("${target_name}" INTERFACE atomic)
  68. endif()
  69. file(REMOVE "${test_file_name}")
  70. file(REMOVE_RECURSE "${test_bindir}")
  71. endfunction()
  72. _juce_create_atomic_target(juce_atomic_wrapper)