Better CMake variable expansion usage in if.
GitOrigin-RevId: 28a5d6bbab13a9eacf9b1b8f0ac8eeff1be21556
This commit is contained in:
parent
078417d423
commit
e785ac6bba
@ -58,7 +58,7 @@ function(add_required_cxx_compiler_flag FLAG)
|
|||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
|
||||||
check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG})
|
check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG})
|
||||||
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
|
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
|
||||||
if (${MANGLED_FLAG})
|
if (MANGLED_FLAG)
|
||||||
set(VARIANT ${ARGV1})
|
set(VARIANT ${ARGV1})
|
||||||
if (ARGV1)
|
if (ARGV1)
|
||||||
string(TOUPPER "_${VARIANT}" VARIANT)
|
string(TOUPPER "_${VARIANT}" VARIANT)
|
||||||
|
@ -59,7 +59,7 @@ endif (NOT DEFINED IOS_PLATFORM)
|
|||||||
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
|
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
|
||||||
|
|
||||||
# Check the platform selection and setup for developer root
|
# Check the platform selection and setup for developer root
|
||||||
if (${IOS_PLATFORM} STREQUAL "OS")
|
if (IOS_PLATFORM STREQUAL "OS")
|
||||||
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
||||||
set (XCODE_IOS_PLATFORM iphoneos)
|
set (XCODE_IOS_PLATFORM iphoneos)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ if (${IOS_PLATFORM} STREQUAL "OS")
|
|||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
||||||
|
|
||||||
set (APPLE_IOS True)
|
set (APPLE_IOS True)
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
|
||||||
set (SIMULATOR_FLAG true)
|
set (SIMULATOR_FLAG true)
|
||||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||||
set (XCODE_IOS_PLATFORM iphonesimulator)
|
set (XCODE_IOS_PLATFORM iphonesimulator)
|
||||||
@ -76,7 +76,7 @@ elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
|||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||||
|
|
||||||
set (APPLE_IOS True)
|
set (APPLE_IOS True)
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "WATCHOS")
|
elseif (IOS_PLATFORM STREQUAL "WATCHOS")
|
||||||
set (IOS_PLATFORM_LOCATION "WatchOS.platform")
|
set (IOS_PLATFORM_LOCATION "WatchOS.platform")
|
||||||
set (XCODE_IOS_PLATFORM watchos)
|
set (XCODE_IOS_PLATFORM watchos)
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ elseif (${IOS_PLATFORM} STREQUAL "WATCHOS")
|
|||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchos")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchos")
|
||||||
|
|
||||||
set (APPLE_WATCH True)
|
set (APPLE_WATCH True)
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "WATCHSIMULATOR")
|
elseif (IOS_PLATFORM STREQUAL "WATCHSIMULATOR")
|
||||||
set (SIMULATOR_FLAG true)
|
set (SIMULATOR_FLAG true)
|
||||||
set (IOS_PLATFORM_LOCATION "WatchSimulator.platform")
|
set (IOS_PLATFORM_LOCATION "WatchSimulator.platform")
|
||||||
set (XCODE_IOS_PLATFORM watchsimulator)
|
set (XCODE_IOS_PLATFORM watchsimulator)
|
||||||
@ -93,7 +93,7 @@ elseif (${IOS_PLATFORM} STREQUAL "WATCHSIMULATOR")
|
|||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchsimulator")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchsimulator")
|
||||||
|
|
||||||
set (APPLE_WATCH True)
|
set (APPLE_WATCH True)
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "TVOS")
|
elseif (IOS_PLATFORM STREQUAL "TVOS")
|
||||||
set (IOS_PLATFORM_LOCATION "AppleTvOS.platform")
|
set (IOS_PLATFORM_LOCATION "AppleTvOS.platform")
|
||||||
set (XCODE_IOS_PLATFORM tvos)
|
set (XCODE_IOS_PLATFORM tvos)
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ elseif (${IOS_PLATFORM} STREQUAL "TVOS")
|
|||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-appletvos")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-appletvos")
|
||||||
|
|
||||||
set (APPLE_TV True)
|
set (APPLE_TV True)
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "TVSIMULATOR")
|
elseif (IOS_PLATFORM STREQUAL "TVSIMULATOR")
|
||||||
set (SIMULATOR_FLAG true)
|
set (SIMULATOR_FLAG true)
|
||||||
set (IOS_PLATFORM_LOCATION "AppleTvSimulator.platform")
|
set (IOS_PLATFORM_LOCATION "AppleTvSimulator.platform")
|
||||||
set (XCODE_IOS_PLATFORM tvsimulator)
|
set (XCODE_IOS_PLATFORM tvsimulator)
|
||||||
@ -110,7 +110,7 @@ elseif (${IOS_PLATFORM} STREQUAL "TVSIMULATOR")
|
|||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-tvsimulator")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-tvsimulator")
|
||||||
|
|
||||||
set (APPLE_TV True)
|
set (APPLE_TV True)
|
||||||
else (${IOS_PLATFORM} STREQUAL "OS")
|
else (IOS_PLATFORM STREQUAL "OS")
|
||||||
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS, SIMULATOR, or WATCHOS.")
|
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS, SIMULATOR, or WATCHOS.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer"
|
|||||||
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||||
if (EXISTS ${XCODE_POST_43_ROOT})
|
if (EXISTS ${XCODE_POST_43_ROOT})
|
||||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
|
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
|
||||||
elseif(EXISTS ${XCODE_PRE_43_ROOT})
|
elseif (EXISTS ${XCODE_PRE_43_ROOT})
|
||||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
|
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
|
||||||
endif (EXISTS ${XCODE_POST_43_ROOT})
|
endif (EXISTS ${XCODE_POST_43_ROOT})
|
||||||
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||||
|
@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|||||||
|
|
||||||
project(TDLib VERSION 1.3.6 LANGUAGES CXX C)
|
project(TDLib VERSION 1.3.6 LANGUAGES CXX C)
|
||||||
|
|
||||||
|
if (POLICY CMP0054)
|
||||||
|
# do not expand quoted arguments
|
||||||
|
cmake_policy(SET CMP0054 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Prevent in-source build
|
# Prevent in-source build
|
||||||
get_filename_component(TD_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
get_filename_component(TD_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
||||||
get_filename_component(TD_REAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH)
|
get_filename_component(TD_REAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH)
|
||||||
@ -105,11 +110,11 @@ if (OPENSSL_FOUND)
|
|||||||
message(STATUS "Found OpenSSL: ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}")
|
message(STATUS "Found OpenSSL: ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
set(GCC 1)
|
set(GCC 1)
|
||||||
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(CLANG 1)
|
set(CLANG 1)
|
||||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
set(INTEL 1)
|
set(INTEL 1)
|
||||||
elseif (NOT MSVC)
|
elseif (NOT MSVC)
|
||||||
message(FATAL_ERROR "Compiler isn't supported")
|
message(FATAL_ERROR "Compiler isn't supported")
|
||||||
@ -669,7 +674,7 @@ if (MEMPROF)
|
|||||||
target_compile_definitions(memprof PRIVATE -DUSE_MEMPROF_SAFE=1)
|
target_compile_definitions(memprof PRIVATE -DUSE_MEMPROF_SAFE=1)
|
||||||
elseif (MEMPROF STREQUAL "FAST")
|
elseif (MEMPROF STREQUAL "FAST")
|
||||||
target_compile_definitions(memprof PRIVATE -DUSE_MEMPROF_FAST=1)
|
target_compile_definitions(memprof PRIVATE -DUSE_MEMPROF_FAST=1)
|
||||||
elseif (NOT ${MEMPROF})
|
elseif (NOT MEMPROF)
|
||||||
message(FATAL_ERROR "Unsupported MEMPROF value \"${MEMPROF}\"")
|
message(FATAL_ERROR "Unsupported MEMPROF value \"${MEMPROF}\"")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -729,7 +734,7 @@ if (TD_ENABLE_DOTNET)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_options(tddotnet PRIVATE "/doc")
|
target_compile_options(tddotnet PRIVATE "/doc")
|
||||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
|
if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||||
set_target_properties(tddotnet PROPERTIES VS_WINRT_COMPONENT "true")
|
set_target_properties(tddotnet PROPERTIES VS_WINRT_COMPONENT "true")
|
||||||
target_compile_options(tddotnet PUBLIC "/ZW")
|
target_compile_options(tddotnet PUBLIC "/ZW")
|
||||||
else()
|
else()
|
||||||
|
@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|||||||
|
|
||||||
project(TdJavaExample VERSION 1.0 LANGUAGES CXX)
|
project(TdJavaExample VERSION 1.0 LANGUAGES CXX)
|
||||||
|
|
||||||
|
if (POLICY CMP0054)
|
||||||
|
# do not expand quoted arguments
|
||||||
|
cmake_policy(SET CMP0054 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Td REQUIRED)
|
find_package(Td REQUIRED)
|
||||||
|
|
||||||
if (NOT JNI_FOUND)
|
if (NOT JNI_FOUND)
|
||||||
@ -58,11 +63,11 @@ target_include_directories(tdjni PRIVATE ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PAT
|
|||||||
target_link_libraries(tdjni PRIVATE Td::TdStatic ${JAVA_JVM_LIBRARY})
|
target_link_libraries(tdjni PRIVATE Td::TdStatic ${JAVA_JVM_LIBRARY})
|
||||||
target_compile_definitions(tdjni PRIVATE PACKAGE_NAME="${TD_API_JAVA_PACKAGE}")
|
target_compile_definitions(tdjni PRIVATE PACKAGE_NAME="${TD_API_JAVA_PACKAGE}")
|
||||||
|
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
set(GCC 1)
|
set(GCC 1)
|
||||||
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(CLANG 1)
|
set(CLANG 1)
|
||||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
set(INTEL 1)
|
set(INTEL 1)
|
||||||
elseif (NOT MSVC)
|
elseif (NOT MSVC)
|
||||||
message(FATAL_ERROR "Compiler isn't supported")
|
message(FATAL_ERROR "Compiler isn't supported")
|
||||||
|
@ -31,7 +31,7 @@ if (NOT WIN32)
|
|||||||
target_compile_definitions(tdsqlite PRIVATE -DHAVE_USLEEP -DNDEBUG=1)
|
target_compile_definitions(tdsqlite PRIVATE -DHAVE_USLEEP -DNDEBUG=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
|
if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||||
target_compile_definitions(tdsqlite PRIVATE -DSQLITE_OS_WINRT=1)
|
target_compile_definitions(tdsqlite PRIVATE -DSQLITE_OS_WINRT=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user