diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..610ab56 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,47 @@ +on: + - push + +jobs: + build-linux: + name: Use clang and gcc via "Unix Makefiles" + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [clang, gcc] + steps: + - uses: actions/checkout@v4 + - run: | + cmake -Bbuild -DCMAKE_C_COMPILER=${{ matrix.compiler }} + cmake --build build + + build-windows-ninja: + name: Use clang and clang-cl via Ninja + runs-on: windows-latest + strategy: + matrix: + # On Windows, clang only enables the WIN32 flag in CMake whereas + # clang-cl also enables MSVC, because it has a cl.exe-like interface. + compiler: [clang, clang-cl] + steps: + - uses: actions/checkout@v4 + - run: | + # Use Ninja because the MSBuild toolchain can only configure + # alternative compilers via "toolsets", where only ClangCL is + # supported. + cmake -Bbuild -GNinja -DCMAKE_C_COMPILER=${{ matrix.compiler }} + cmake --build build + + build-windows-msbuild: + name: Use MSVC and clang-cl via MSBuild + runs-on: windows-latest + strategy: + matrix: + toolset: + # The default toolset should be the latest 'v143' when nothing is specified + - + - -TClangCL + steps: + - uses: actions/checkout@v4 + - run: | + cmake -Bbuild ${{ matrix.toolset }} + cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a9a694..b2ae9e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ target_include_directories(${PROJECT_NAME} $) target_link_libraries(${PROJECT_NAME} - PUBLIC $<$>:m>) + PUBLIC $<$>:m>) set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} diff --git a/Makefile b/Makefile index c43a479..e14b66a 100644 --- a/Makefile +++ b/Makefile @@ -72,12 +72,11 @@ ifneq ($(shared), not-set) endif define run-config -mkdir -p $(BUILDDIR) -cd $(BUILDDIR) && cmake $(CURDIR) $(CONFIG_FLAGS) +cmake $(CURDIR) -B"$(BUILDDIR)" $(CONFIG_FLAGS) endef all clean install: $(BUILDDIR) - make -C $(BUILDDIR) $@ + cmake --build $(BUILDDIR) $@ uninstall: xargs rm < $(BUILDDIR)/install_manifest.txt diff --git a/cmake/GKlibSystem.cmake b/cmake/GKlibSystem.cmake deleted file mode 100644 index 249d424..0000000 --- a/cmake/GKlibSystem.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# Helper modules. - -# Add compiler flags. -if(MSVC) - set(GKlib_COPTS "/Ox") - set(GKlib_COPTIONS "-DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE -DUSE_GKREGEX") -elseif(MINGW) - set(GKlib_COPTS "-DUSE_GKREGEX") -else() - set(GKlib_COPTIONS "-DLINUX -D_FILE_OFFSET_BITS=64") -endif(MSVC) - -if(CYGWIN) - set(GKlib_COPTIONS "${GKlib_COPTIONS} -DCYGWIN") -endif(CYGWIN) - -if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") -# GCC opts. - set(GKlib_COPTIONS "${GKlib_COPTIONS} -std=c99 -fno-strict-aliasing") - - if(VALGRIND) - set(GKlib_COPTIONS "${GK_COPTIONS} -march=x86-64 -mtune=generic") - else() - set(GKlib_COPTIONS "${GKlib_COPTIONS} -march=native") - endif(VALGRIND) - - if(NOT MINGW) - set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC") - endif(NOT MINGW) - -# GCC warnings. - set(GKlib_COPTIONS "${GKlib_COPTIONS} -Werror -Wall -pedantic -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label") -endif() - -if(${CMAKE_C_COMPILER_ID} MATCHES "Sun") - set(GKlib_COPTIONS "${GKlib_COPTIONS} -xc99") -endif() - -# Intel compiler -if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") - set(GKlib_COPTIONS "${GKlib_COPTIONS} -xHost -std=c99") -endif() - -# Set the CPU type -if(NO_X86) - set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNO_X86=${NO_X86}") -endif(NO_X86) - - -# Finally set the official C flags. -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GKlib_COPTIONS} ${GKlib_COPTS}") diff --git a/include/gk_arch.h b/include/gk_arch.h index b82fb6a..b05192a 100644 --- a/include/gk_arch.h +++ b/include/gk_arch.h @@ -53,7 +53,7 @@ /************************************************************************* * Architecture-specific modifications **************************************************************************/ -#ifdef WIN32 +#ifdef _WIN32 typedef ptrdiff_t ssize_t; #endif diff --git a/src/error.c b/src/error.c index e2a18cf..bf7ac72 100644 --- a/src/error.c +++ b/src/error.c @@ -174,7 +174,7 @@ void gk_NonLocalExit_Handler(int signum) /**************************************************************************/ char *gk_strerror(int errnum) { -#if defined(WIN32) || defined(__MINGW32__) +#if defined(_WIN32) || defined(__MINGW32__) return strerror(errnum); #else #ifndef SUNOS diff --git a/src/string.c b/src/string.c index 4a3fb14..a7fb551 100644 --- a/src/string.c +++ b/src/string.c @@ -483,7 +483,7 @@ char *gk_time2str(time_t time) -#if !defined(WIN32) && !defined(__MINGW32__) +#if !defined(_WIN32) && !defined(__MINGW32__) /************************************************************************/ /*! \brief Converts a date/time string into its equivalent time_t value diff --git a/src/timers.c b/src/timers.c index bb8f296..3c4030b 100644 --- a/src/timers.c +++ b/src/timers.c @@ -39,7 +39,7 @@ double gk_CPUSeconds(void) #ifdef __OPENMPXXXX__ return omp_get_wtime(); #else - #if defined(WIN32) || defined(__MINGW32__) + #if defined(_WIN32) || defined(__MINGW32__) return((double) clock()/CLOCKS_PER_SEC); #else struct rusage r;