Skip to content

Commit

Permalink
Adding cmake platform defines and detection.
Browse files Browse the repository at this point in the history
Removed acl_compressor from android build for now.
  • Loading branch information
nfrechette committed Mar 3, 2018
1 parent 8a5dad5 commit 52f41a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

include(CMakeUtils)
include(CMakeCompiler)
include(CMakePlatforms)

set(USE_AVX_INSTRUCTIONS false CACHE BOOL "Use AVX instructions")
set(CPU_INSTRUCTION_SET false CACHE STRING "CPU instruction set")
Expand Down Expand Up @@ -33,5 +34,7 @@ endif()
enable_testing()

# Add other projects
add_subdirectory("${PROJECT_SOURCE_DIR}/tools/acl_compressor")
if(PLATFORM_WINDOWS OR PLATFORM_OSX OR PLATFORM_LINUX)
add_subdirectory("${PROJECT_SOURCE_DIR}/tools/acl_compressor")
endif()
add_subdirectory("${PROJECT_SOURCE_DIR}/tests")
20 changes: 20 additions & 0 deletions cmake/CMakePlatforms.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.2)

# Detect which platform we have
if( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
set(PLATFORM_WINDOWS 1)
set(PLATFORM_NAME "Windows")
elseif( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
set(PLATFORM_OSX 1)
set(PLATFORM_NAME "OS X")
elseif( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
set(PLATFORM_LINUX 1)
set(PLATFORM_NAME "Linux")
elseif( ${CMAKE_SYSTEM_NAME} STREQUAL "Android" )
set(PLATFORM_ANDROID 1)
set(PLATFORM_NAME "Android")
else()
message(FATAL_ERROR "Unknown platform ${CMAKE_SYSTEM_NAME}!")
endif()

message(STATUS "Detected platform: ${PLATFORM_NAME}")

0 comments on commit 52f41a0

Please sign in to comment.