Skip to content

Commit

Permalink
Refactor check for supported platform, also run it via CHECK_C_SOURCE…
Browse files Browse the repository at this point in the history
…_COMPILES.

This way we hopefully fail to compile earlier, at cmake time
as opposed to halfway-in.
  • Loading branch information
LebedevRI committed Aug 29, 2016
1 parent a099300 commit 353e3a8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 40 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ else()
MESSAGE(STATUS "Found little endian system. Good.")
endif(${BIGENDIAN})

check_c_source_compiles("
int main() {
#include \"${CMAKE_SOURCE_DIR}/src/is_supported_platform.h\"
}" IS_SUPPORTED_PLATFORM)
if(NOT IS_SUPPORTED_PLATFORM)
MESSAGE(FATAL_ERROR "The target platform is not supported!")
endif(NOT IS_SUPPORTED_PLATFORM)
MESSAGE(STATUS "Is the target platform supported: ${IS_SUPPORTED_PLATFORM}")

if(APPLE)
option(USE_MAC_INTEGRATION "Enable OS X integration" ON)
else(APPLE)
Expand Down
41 changes: 1 addition & 40 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,46 +449,7 @@ int dt_init(int argc, char *argv[], const int init_gui, lua_State *L)
_dt_sigsegv_old_handler = signal(SIGSEGV, &_dt_sigsegv_handler);
#endif

#if !defined(__BYTE_ORDER__) || __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
#error "Unfortunately we only work on litte-endian systems."
#endif

#if(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(__i386__) \
|| defined(__i386))
#define DT_SUPPORTED_X86 1
#else
#define DT_SUPPORTED_X86 0
#endif

#if defined(__aarch64__) && defined(__ARM_64BIT_STATE) && defined(__ARM_ARCH) && defined(__ARM_ARCH_8A)
#define DT_SUPPORTED_ARMv8A 1
#else
#define DT_SUPPORTED_ARMv8A 0
#endif

#if !DT_SUPPORTED_X86 && !DT_SUPPORTED_ARMv8A
#error "Unfortunately we only work on amd64/x86 (64-bit and maybe 32-bit) and ARMv8-A (64-bit only)."
#endif

#if !DT_SUPPORTED_X86
#if !defined(__SIZEOF_POINTER__) || __SIZEOF_POINTER__ < 8
#error "On non-x86, we only support 64-bit."
#else
if(sizeof(void *) < 8)
{
fprintf(stderr, "[dt_init] On non-x86, we only support 64-bit.\n");
return 1;
}
#endif
#endif

#undef DT_SUPPORTED_ARMv8A
#undef DT_SUPPORTED_X86

#if !defined(__SSE2__) || !defined(__SSE__)
#pragma message "Building without SSE2 is highly experimental."
#pragma message "Expect a LOT of functionality to be broken. You have been warned."
#endif
#include "is_supported_platform.h"

int sse2_supported = 0;

Expand Down
66 changes: 66 additions & 0 deletions src/is_supported_platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
This file is part of darktable,
copyright (c) 2016 Roman Lebedev.
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
darktable is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/

#if !defined(__BYTE_ORDER__) || __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
#error "Unfortunately we only work on litte-endian systems."
#endif

#if(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(__i386__) \
|| defined(__i386))
#define DT_SUPPORTED_X86 1
#else
#define DT_SUPPORTED_X86 0
#endif

#if defined(__aarch64__) && defined(__ARM_64BIT_STATE) && defined(__ARM_ARCH) && defined(__ARM_ARCH_8A)
#define DT_SUPPORTED_ARMv8A 1
#else
#define DT_SUPPORTED_ARMv8A 0
#endif

#if DT_SUPPORTED_X86 && DT_SUPPORTED_ARMv8A
#error "Looks like hardware platform detection macros are broken?"
#endif

#if !DT_SUPPORTED_X86 && !DT_SUPPORTED_ARMv8A
#error "Unfortunately we only work on amd64/x86 (64-bit and maybe 32-bit) and ARMv8-A (64-bit only)."
#endif

#if !DT_SUPPORTED_X86
#if !defined(__SIZEOF_POINTER__) || __SIZEOF_POINTER__ < 8
#error "On non-x86, we only support 64-bit."
#else
if(sizeof(void *) < 8)
{
fprintf(stderr, "[dt_init] On non-x86, we only support 64-bit.\n");
return 1;
}
#endif
#endif

#undef DT_SUPPORTED_ARMv8A
#undef DT_SUPPORTED_X86

#if !defined(__SSE2__) || !defined(__SSE__)
#pragma message "Building without SSE2 is highly experimental."
#pragma message "Expect a LOT of functionality to be broken. You have been warned."
#endif

// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
// vim: shiftwidth=2 expandtab tabstop=2 cindent
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;

0 comments on commit 353e3a8

Please sign in to comment.