Mercurial > hg > orthanc-databases
annotate Resources/PostgreSQL/CheckTypeAlignment.cmake @ 463:0d168a2cadec pg-transactions
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 31 Jan 2024 14:53:37 +0100 |
parents | 8c7bb94adff7 |
children |
rev | line source |
---|---|
172
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 macro(CHECK_TYPE_ALIGNMENT TYPE NAME) |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 if(NOT ${NAME}) |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 message(STATUS "Check alignment of ${TYPE}") |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 set(INCLUDE_HEADERS "#include <stddef.h> |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 #include <stdio.h> |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 #include <stdlib.h>") |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 if(HAVE_STDINT_H) |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 set(INCLUDE_HEADERS "${INCLUDE_HEADERS}\n#include <stdint.h>\n") |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 endif(HAVE_STDINT_H) |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_${NAME}_alignment.c" |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 "${INCLUDE_HEADERS} |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 int main(){ |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 char diff; |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 struct foo {char a; ${TYPE} b;}; |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 struct foo *p = (struct foo *) malloc(sizeof(struct foo)); |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 diff = ((char *)&p->b) - ((char *)&p->a); |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 return diff;} |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 ") |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 try_run(${NAME} COMPILE_RESULT "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/" |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_${NAME}_alignment.c") |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 message(STATUS "Check alignment of ${TYPE} - ${${NAME}}") |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 endif(NOT ${NAME}) |
8c7bb94adff7
trying upgrade from libpq 9.6.1 to 13.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 endmacro() |