Skip to content

Commit

Permalink
Merge pull request #6 from Mahesh1998/cmake_build_work
Browse files Browse the repository at this point in the history
MSVC Cmake
  • Loading branch information
HuidaeCho committed Sep 15, 2024
2 parents ec0fc42 + 8125579 commit 3ebded4
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 13 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ set(HTML2MAN VERSION_NUMBER=${GRASS_VERSION_NUMBER} ${PYTHON_EXECUTABLE}

if(WIN32)
set(sep "\;")
set(env_path "")
else()
set(sep ":")
set(env_path ":$ENV{PATH}")
endif()

set(env_path "$ENV{PATH}")

set(grass_env_command
${CMAKE_COMMAND} -E env "PATH=${BIN_DIR}${sep}${SCRIPTS_DIR}${env_path}"
${CMAKE_COMMAND} -E env "PATH=${BIN_DIR}${sep}${SCRIPTS_DIR}${sep}${env_path}"
"PYTHONPATH=${ETC_PYTHON_DIR}${sep}${GUI_WXPYTHON_DIR}${sep}$ENV{PYTHONPATH}"
"LD_LIBRARY_PATH=${LIB_DIR}${sep}$ENV{LD_LIBRARY_PATH}"
"GISBASE=${RUN_GISBASE_NATIVE}" "GISRC=${GISRC}" "LC_ALL=C" "LANG=C"
Expand Down
11 changes: 4 additions & 7 deletions cmake/modules/CheckDependentLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ find_package(FLEX REQUIRED)

find_package(BISON REQUIRED)

if(UNIX)
find_library(MATH_LIBRARY m)
add_library(LIBM INTERFACE IMPORTED GLOBAL)
set_property(TARGET LIBM PROPERTY INTERFACE_LINK_LIBRARIES ${MATH_LIBRARY})
mark_as_advanced(M_LIBRARY)
message("!!! MATH_LIBRARY: ${MATH_LIBRARY}")
endif()
find_library(MATH_LIBRARY m)
add_library(LIBM INTERFACE IMPORTED GLOBAL)
set_property(TARGET LIBM PROPERTY INTERFACE_LINK_LIBRARIES ${MATH_LIBRARY})
mark_as_advanced(M_LIBRARY)

find_package(PROJ REQUIRED)
if(PROJ_FOUND)
Expand Down
5 changes: 5 additions & 0 deletions include/grass/defs/glocale.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef GRASS_GLOCALEDEFS_H
#define GRASS_GLOCALEDEFS_H

#if !defined __GNUC__ || __GNUC__ < 2
#undef __attribute__
#define __attribute__(x)
#endif

extern void G_init_locale(void);
extern char *G_gettext(const char *, const char *)
__attribute__((format_arg(2)));
Expand Down
4 changes: 2 additions & 2 deletions lib/db/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
file(GLOB dbmibase_SRCS "./dbmi_base/*.c")
if(MSVC)
set(dbmibase_INCLUDES "./dbmi_base" "./dbmi_base/msvc")
list(APPEND dbmibase_SRCS "./dbmi_base/msvc/dirent.c")
set(dbmibase_INCLUDES "./dbmi_base" "../../msvc")
list(APPEND dbmibase_SRCS "../../msvc/dirent.c")
endif()

build_library_in_subdir(
Expand Down
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions msvc/gettimeofday.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* win32gettimeofday.c
* Win32 gettimeofday() replacement
*
* src/port/win32gettimeofday.c
*
* Copyright (c) 2003 SRA, Inc.
* Copyright (c) 2003 SKC, Inc.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose, without fee, and without a
* written agreement is hereby granted, provided that the above
* copyright notice and this paragraph and the following two
* paragraphs appear in all copies.
*
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/

#include "c.h"

#include <sysinfoapi.h>

#include <sys/time.h>

/* FILETIME of Jan 1 1970 00:00:00, the PostgreSQL epoch */
static const unsigned __int64 epoch = UINT64CONST(116444736000000000);

/*
* FILETIME represents the number of 100-nanosecond intervals since
* January 1, 1601 (UTC).
*/
#define FILETIME_UNITS_PER_SEC 10000000L
#define FILETIME_UNITS_PER_USEC 10


/*
* timezone information is stored outside the kernel so tzp isn't used anymore.
*
* Note: this function is not for Win32 high precision timing purposes. See
* elapsed_time().
*/
int
gettimeofday(struct timeval *tp, void *tzp)
{
FILETIME file_time;
ULARGE_INTEGER ularge;

/*
* POSIX declines to define what tzp points to, saying "If tzp is not a
* null pointer, the behavior is unspecified". Let's take this
* opportunity to verify that noplace in Postgres tries to use any
* unportable behavior.
*/
Assert(tzp == NULL);

GetSystemTimePreciseAsFileTime(&file_time);
ularge.LowPart = file_time.dwLowDateTime;
ularge.HighPart = file_time.dwHighDateTime;

tp->tv_sec = (long) ((ularge.QuadPart - epoch) / FILETIME_UNITS_PER_SEC);
tp->tv_usec = (long) (((ularge.QuadPart - epoch) % FILETIME_UNITS_PER_SEC)
/ FILETIME_UNITS_PER_USEC);

return 0;
}
2 changes: 1 addition & 1 deletion utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generate_last_commit_file.py

set(current_time_s_ms_SRCS "timer/main.c")
if(MSVC)
list(APPEND current_time_s_ms_SRCS "timer/msvc/gettimeofday.c")
list(APPEND current_time_s_ms_SRCS "../msvc/gettimeofday.c")
endif()
build_program_in_subdir(
timer
Expand Down

0 comments on commit 3ebded4

Please sign in to comment.