set(CMAKE_CXX_STANDARD 11)
#set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
+# check that the ARCH (target architecture) variable is defined
if(NOT ARCH)
- set(ARCH i386)
+ message(FATAL_ERROR "Target architecture (ARCH) is not defined. Please, choose one of: i386, amd64, arm")
endif()
# Now the ARCH variable will be in lowercase.
# It is needed because STREQUAL comparison
# for more information.
string(TOLOWER ${ARCH} ARCH)
+# set possible values for cmake GUI
+set_property(CACHE ARCH PROPERTY STRINGS "i386" "amd64" "arm")
+
# Alternative WinNT-compatible architecture string
if(ARCH STREQUAL "i386")
set(WINARCH "x86")
-if(NOT ARCH)
- set(ARCH i386)
-endif()
-
if(DEFINED ENV{_ROSBE_ROSSCRIPTDIR})
set(CMAKE_SYSROOT $ENV{_ROSBE_ROSSCRIPTDIR}/$ENV{ROS_ARCH})
endif()
+# pass variables necessary for the toolchain (needed for try_compile)
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH CLANG_VERSION)
+
# The name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
# The processor we are targeting
elseif(ARCH STREQUAL "arm")
set(CMAKE_SYSTEM_PROCESSOR arm)
else()
- message(ERROR "Unsupported ARCH: ${ARCH}")
+ message(FATAL_ERROR "Unsupported ARCH: ${ARCH}")
endif()
if (DEFINED CLANG_VERSION)
-if(NOT ARCH)
- set(ARCH i386)
-endif()
-
# Default to Debug for the build type
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif()
+# pass variables necessary for the toolchain (needed for try_compile)
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH)
+
# Choose the right MinGW toolchain prefix
if(NOT DEFINED MINGW_TOOLCHAIN_PREFIX)
if(ARCH STREQUAL "i386")
-if(NOT ARCH)
- set(ARCH i386)
-endif()
-
# Default to Debug for the build type
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif()
+# pass variables necessary for the toolchain (needed for try_compile)
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH USE_CLANG_CL)
+
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR i686)