Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Windows CI back #1290

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/awesome_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ jobs:
needs: [MainSequence]
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
os: [windows-latest, ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: |
cmake -B ./build -S .
cmake --build build
cmake --build build --config Release
- name: Label on PR fail
uses: actions/github-script@v6
if: ${{ failure() && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' }}
Expand Down
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
cmake_minimum_required(VERSION 3.22)
project(Algorithms_in_C
LANGUAGES C
VERSION 1.0.0
DESCRIPTION "Set of algorithms implemented in C."
)
LANGUAGES C
VERSION 1.0.0
DESCRIPTION "Set of algorithms implemented in C."
)

# Set compilation standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED YES)

if(MSVC)
if (MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# add_compile_options(/Za)
endif(MSVC)
endif (MSVC)

# check for math library
# addresses a bug when linking on OSX
Expand Down
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* [Rot13](https://github.com/TheAlgorithms/C/blob/HEAD/cipher/rot13.c)

## Client Server
* [Bool](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/bool.h)
* [Client](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/client.c)
* [Fork](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/fork.h)
* [Remote Command Exec Udp Client](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/remote_command_exec_udp_client.c)
* [Remote Command Exec Udp Server](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/remote_command_exec_udp_server.c)
* [Server](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/server.c)
Expand Down
24 changes: 15 additions & 9 deletions client_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ else()
CHECK_INCLUDE_FILE(arpa/inet.h ARPA_HEADERS)
endif()

include(CheckSymbolExists)
if(ARPA_HEADERS OR WINSOCK_HEADER)
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
# with full pathname. RELATIVE may makes it easier to extract an executable name
Expand All @@ -15,16 +16,21 @@ if(ARPA_HEADERS OR WINSOCK_HEADER)
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
foreach( testsourcefile ${APP_SOURCES} )
# I used a simple string replace, to cut off .cpp.
string( REPLACE ".c" "" testname ${testsourcefile} )
add_executable( ${testname} ${testsourcefile} )

if(OpenMP_C_FOUND)
target_link_libraries(${testname} PRIVATE OpenMP::OpenMP_C)
string(REPLACE ".c" "" testname ${testsourcefile})

if(NOT WIN32)
if(${testname} STREQUAL "fork" OR ${testname} STREQUAL "bool")
continue()
endif()
endif()
if(MATH_LIBRARY)
add_executable(${testname} ${testsourcefile})

if (OpenMP_C_FOUND)
target_link_libraries(${testname} PRIVATE OpenMP::OpenMP_C)
endif ()
if (MATH_LIBRARY)
target_link_libraries(${testname} PRIVATE ${MATH_LIBRARY})
endif()

endif ()
# if(HAS_UNISTD)
# target_compile_definitions(${testname} PRIVATE HAS_UNISTD)
# endif()
Expand All @@ -34,7 +40,7 @@ if(ARPA_HEADERS OR WINSOCK_HEADER)
# target_compile_definitions(${testname} PRIVATE WINSOCK_HEADER)
# endif()

if(WINSOCK_HEADER)
if (WINSOCK_HEADER)
target_link_libraries(${testname} PRIVATE ws2_32) # link winsock library on windows
endif()

Expand Down
55 changes: 55 additions & 0 deletions client_server/bool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2007 - INRIA
*
* Copyright (C) 2012 - 2016 - Scilab Enterprises
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* This file was originally licensed under the terms of the CeCILL v2.1,
* and continues to be available under such terms.
* For more information, see the COPYING file which you should have received
* along with this program.
*
*/
#ifndef __BOOL_H__
#define __BOOL_H__

/* define boolean type */
#ifdef BOOL
#undef BOOL
#endif

#ifdef TRUE
#undef TRUE
#endif

#ifdef FALSE
#undef FALSE
#endif


#ifndef _MSC_VER
typedef enum
{
FALSE = 0,
TRUE = 1
} BOOL;

#else
/* Please notice that BOOL is defined in <windef.h> */
/* BUT windef.h includes all others windows include */
/* it is better to redefine as */
typedef int BOOL;
#define FALSE 0
#define TRUE 1

#endif
/* converts BOOL to bool */
#define BOOLtobool(w) ((w != FALSE) ? true : false)

/* converts bool to BOOL */
#define booltoBOOL(w) ((w == true) ? TRUE : FALSE)

#endif /* __BOOL_H__ */
/*--------------------------------------------------------------------------*/
Loading