Skip to content

Instantly share code, notes, and snippets.

View DenisRitchie's full-sized avatar
:octocat:
Contribuyendo a la comunidad

Denis West DenisRitchie

:octocat:
Contribuyendo a la comunidad
View GitHub Profile
@DenisRitchie
DenisRitchie / converter.c
Created April 30, 2021 11:41 — forked from ozdemirburak/converter.c
UTF8, UTF16, UTF32, ISO8859 conversions
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include <stddef.h>
int getSize(unsigned char *);
unsigned char * fileToBuffer(unsigned char *);
unsigned char * replaceCharset(const char *, const char *, const char *);
@DenisRitchie
DenisRitchie / AsyncHelper.cs
Created February 12, 2021 11:52 — forked from ChrisMcKee/AsyncHelper.cs
AsyncHelpers to simplify calling of Async/Task methods from synchronous context. (use https://github.com/aspnet/AspNetIdentity/blob/master/src/Microsoft.AspNet.Identity.Core/AsyncHelper.cs this is ancient code)
namespace My.Common
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
public static class AsyncHelpers
{
/// <summary>
@DenisRitchie
DenisRitchie / settings.json
Last active February 19, 2024 03:14
Pelles C IDE - Visual Studio Code Configurations
//
// https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
//
{
"editor.tabSize": 2,
"editor.tabCompletion": "on",
"editor.insertSpaces": true,
"editor.trimAutoWhitespace": true,
"editor.letterSpacing": 0,
"editor.autoIndent": "advanced",
@DenisRitchie
DenisRitchie / linux_input.c
Created June 11, 2020 16:21 — forked from uobikiemukot/linux_input.c
test program of reading /dev/input/event*
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/input.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdint.h>
@DenisRitchie
DenisRitchie / CMakeLists.txt
Created April 21, 2020 04:23 — forked from socantre/CMakeLists.txt
Example of using add_custom_command and add_custom_target together in CMake to handle custom build steps with minimal rebuilding: This example untars library headers for an INTERFACE library target
set(LIBFOO_TAR_HEADERS
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo_utils.h"
)
add_custom_command(OUTPUT ${LIBFOO_TAR_HEADERS}
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar"
COMMAND ${CMAKE_COMMAND} -E touch ${LIBFOO_TAR_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/foo"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar"

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft