Show bonus/malus timer text if available
[ryzomcore.git] / CMakeModules / OSXToolChain.cmake
blobd480c13b8428a8fac3a039a5c17ff5574e74af2c
1 # Define OSX_SDK to force a specific version such as : -DOSX_SDK=10.11\r
2 #\r
3 # Example:\r
4 # cmake .. -DCMAKE_TOOLCHAIN_FILE=$CMAKE_MODULE_PATH/OSXToolChain.cmake -DOSX_SDK=10.14 <other flags>\r
5 \r
6 # Don't forget to define environment variables:\r
7 #\r
8 # export MACOSX_DEPLOYMENT_TARGET=10.8\r
9 # export OSXCROSS_GCC_NO_STATIC_RUNTIME=1\r
10 # export PATH=$PATH:/home/src/osxcross/target/bin\r
11 #\r
12 # ln -s /usr/bin/hg /home/src/osxcross/target/bin/hg\r
13 #\r
14 # To install all dependencies:\r
15 # ./osxcross-macports install libxml2 jpeg curl libogg libvorbis freetype boost openssl zlib lua-5.3 giflib\r
17 # to compile Luabind\r
18 # cmake .. -DCMAKE_TOOLCHAIN_FILE=$CMAKE_MODULE_PATH/OSXToolChain.cmake -DWITH_SHARED=OFF -DWITH_STATIC=ON -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_INSTALL_PREFIX=$HOME/osxcross/target/external\r
20 IF(DEFINED CMAKE_CROSSCOMPILING)\r
21   # subsequent toolchain loading is not really needed\r
22   RETURN()\r
23 ENDIF()\r
25 # OSXCROSS_TARGET\r
26 # OSXCROSS_SDK\r
28 # Force the compilers to Clang for OS X\r
30 SET(OSXCROSS_HOST "x86_64-apple-darwin18")\r
32 # C\r
33 SET(CMAKE_C_COMPILER ${OSXCROSS_HOST}-clang)\r
34 SET(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11")\r
35 SET(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert")\r
36 SET(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")\r
37 SET(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros")\r
38 SET(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert")\r
40 # C++\r
41 SET(CMAKE_CXX_COMPILER ${OSXCROSS_HOST}-clang++)\r
42 SET(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17")\r
43 SET(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")\r
44 SET(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")\r
45 SET(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")\r
46 SET(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")\r
48 # make\r
49 SET(CMAKE_MAKE_PROGRAM make)\r
51 # Skip the platform compiler checks for cross compiling.\r
52 SET(CMAKE_CXX_COMPILER_FORCED TRUE)\r
53 SET(CMAKE_C_COMPILER_FORCED TRUE)\r
55 # Check if osxcross is installed\r
56 EXECUTE_PROCESS(COMMAND which ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE COMPILER_FULLPATH OUTPUT_STRIP_TRAILING_WHITESPACE)\r
58 IF(NOT COMPILER_FULLPATH)\r
59   MESSAGE(FATAL_ERROR "Unable to find ${CMAKE_CXX_COMPILER}, are you sure osxcross is installed and is in PATH?")\r
60 ENDIF()\r
62 # Default paths\r
63 GET_FILENAME_COMPONENT(CMAKE_OSX_TOOLCHAIN_ROOT ${COMPILER_FULLPATH} DIRECTORY)\r
65 # Parent directory\r
66 GET_FILENAME_COMPONENT(CMAKE_OSX_TOOLCHAIN_ROOT ${CMAKE_OSX_TOOLCHAIN_ROOT} DIRECTORY)\r
68 SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_TOOLCHAIN_ROOT}/SDK)\r
69 SET(MACPORTS_ROOT_DIR ${CMAKE_OSX_TOOLCHAIN_ROOT}/macports/pkgs/opt/local)\r
70 SET(EXTERNAL_OSX_PATH ${CMAKE_OSX_TOOLCHAIN_ROOT}/external)\r
72 # List of all SDKs that have been found\r
73 SET(OSX_SDKS)\r
75 FILE(GLOB _CMAKE_OSX_SDKS "${CMAKE_OSX_SYSROOT}/MacOSX*")\r
76 IF(_CMAKE_OSX_SDKS)\r
77   LIST(SORT _CMAKE_OSX_SDKS)\r
78   LIST(REVERSE _CMAKE_OSX_SDKS)\r
79   FOREACH(_CMAKE_OSX_SDK ${_CMAKE_OSX_SDKS})\r
80     STRING(REGEX REPLACE ".+MacOSX([0-9.]+)\\.sdk" "\\1" _OSX_SDK "${_CMAKE_OSX_SDK}")\r
81     LIST(APPEND OSX_SDKS ${_OSX_SDK})\r
82   ENDFOREACH()\r
83 ENDIF()\r
85 # Find and use the most recent OS X sdk\r
86 IF(NOT OSX_SDKS)\r
87   MESSAGE(FATAL_ERROR "No OS X SDK's found in default search path ${CMAKE_OSX_SYSROOT}.")\r
88 ENDIF()\r
90 # if a specific SDK is defined, try to use it\r
91 IF(OSX_SDK)\r
92   LIST(FIND OSX_SDKS "${OSX_SDK}" _INDEX)\r
93   IF(_INDEX EQUAL -1)\r
94     # if specified SDK doesn't exist, use the last one\r
95     LIST(GET OSX_SDKS 0 OSX_SDK)\r
96   ENDIF()\r
97 ELSE()\r
98   # use the last SDK\r
99   LIST(GET OSX_SDKS 0 OSX_SDK)\r
100 ENDIF()\r
102 MESSAGE(STATUS "Using OS X SDK ${OSX_SDK}")\r
104 # Define final OS X sysroot\r
105 SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}/MacOSX${OSX_SDK}.sdk)\r
107 # Standard settings\r
108 SET(CMAKE_SYSTEM_NAME Darwin)\r
109 SET(CMAKE_SYSTEM "Darwin-18.0.0")\r
110 SET(CMAKE_SYSTEM_VERSION "18.0.0")\r
111 SET(CMAKE_SYSTEM_PROCESSOR "x86_64")\r
113 SET(UNIX ON)\r
114 SET(APPLE ON)\r
116 # Set the find root to the OS X developer roots and to user defined paths\r
117 SET(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_TOOLCHAIN_ROOT} ${CMAKE_OSX_SYSROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} ${MACPORTS_ROOT_DIR} ${EXTERNAL_OSX_PATH} $ENV{EXTERNAL_OSX_PATH} CACHE STRING "OS X find search path root")\r
119 # default to searching for frameworks first\r
120 SET(CMAKE_FIND_FRAMEWORK FIRST)\r
122 # set up the default search directories for frameworks\r
123 SET(CMAKE_SYSTEM_FRAMEWORK_PATH\r
124   ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks\r
125   ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks\r
126   ${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks\r
129 # only search the OS X sdks, not the remainder of the host filesystem\r
130 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\r
131 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\r
132 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\r
133 SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)\r
135 # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH\r
136 INCLUDE(CMakeFindBinUtils)\r
138 set(CMAKE_AR "${OSXCROSS_HOST}-ar" CACHE FILEPATH "ar")\r
139 set(CMAKE_RANLIB "${OSXCROSS_HOST}-ranlib" CACHE FILEPATH "ranlib")\r
140 set(CMAKE_INSTALL_NAME_TOOL "${OSXCROSS_HOST}-install_name_tool" CACHE FILEPATH "install_name_tool")\r
142 set(ENV{PKG_CONFIG_LIBDIR} "${MACPORTS_ROOT_DIR}/lib/pkgconfig")\r
143 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_OSX_TOOLCHAIN_ROOT}/macports/pkgs")\r