Skip to content

Commit

Permalink
Merge pull request #3642 from rouault/fix_3639
Browse files Browse the repository at this point in the history
Fix build errors with Cygwin (fixes #3639)
  • Loading branch information
rouault authored Mar 5, 2023
2 parents bccfd80 + 5329f80 commit a4caae4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#define FROM_PROJ_CPP
#endif

// proj_config.h must be included before testing HAVE_LIBDL
#include "proj_config.h"

#if defined(HAVE_LIBDL) && !defined(_GNU_SOURCE)
// Required for dladdr() on Cygwin
#define _GNU_SOURCE
Expand All @@ -50,8 +53,6 @@

#include <sys/stat.h>

#include "proj_config.h"

#ifdef _WIN32
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#define UWP 1
Expand Down
25 changes: 21 additions & 4 deletions src/proj_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,21 @@
*/
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#ifndef M_1_PI
#define M_1_PI 0.318309886183790671538
#endif

#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif

#ifndef M_PI_4
#define M_PI_4 0.78539816339744830962
#endif

#ifndef M_2_PI
#define M_2_PI 0.63661977236758134308
#endif

Expand All @@ -143,10 +156,14 @@
#endif

/* some more useful math constants and aliases */
#define M_FORTPI M_PI_4 /* pi/4 */
#define M_HALFPI M_PI_2 /* pi/2 */
#define M_PI_HALFPI 4.71238898038468985769 /* 1.5*pi */
#define M_TWOPI 6.28318530717958647693 /* 2*pi */
#define M_FORTPI M_PI_4 /* pi/4 */
#define M_HALFPI M_PI_2 /* pi/2 */
#define M_PI_HALFPI 4.71238898038468985769 /* 1.5*pi */

#ifndef M_TWOPI
#define M_TWOPI 6.28318530717958647693 /* 2*pi */
#endif

#define M_TWO_D_PI M_2_PI /* 2/pi */
#define M_TWOPI_HALFPI 7.85398163397448309616 /* 2.5*pi */

Expand Down
8 changes: 8 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ message(STATUS "Using internal GTest")
configure_file(
${PROJ_SOURCE_DIR}/test/googletest/CMakeLists.txt.in
${PROJ_BINARY_DIR}/googletest-download/CMakeLists.txt)

if(CYGWIN)
# needed at least with gcc 11.3.0 Cygwin, otherwise build errors in
# in googletest-src/googletest/include/gtest/internal/gtest-port.h related to
# fileno() and other functions, when building gtest or including it
add_definitions(-D_GNU_SOURCE)
endif()

execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${PROJ_BINARY_DIR}/googletest-download)
Expand Down

0 comments on commit a4caae4

Please sign in to comment.