Skip to content

Instantly share code, notes, and snippets.

@caiorss
caiorss / CMakeLists.txt
Created July 5, 2020 19:25
Cmake project with nested directories
cmake_minimum_required(VERSION 3.9)
project(CMake_With_Makefile)
#========== Global Configurations =============#
#----------------------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
function(ADD_RUN_TARGET tname target)
@caiorss
caiorss / unix-mmap-class.cpp
Last active December 3, 2022 01:37
Unix/Linux memory mapped files sample code
#include <iostream>
#include <string>
#include <fstream>
#include <cstdint>
#include <cassert>
// --- Unix/Posix headers ---------//
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
@caiorss
caiorss / CMakeLists.txt
Last active June 21, 2020 23:27
Portable Linux Binaries - GLIBC Hell
cmake_minimum_required(VERSION 3.9)
project(Simple_Cmake_Project)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
#========== Targets Configurations ============#
add_executable( filesys filesys.cpp )
target_link_libraries( filesys stdc++fs)
@caiorss
caiorss / unix-process.cpp
Created June 20, 2020 22:16
C++ code for testing Unix's exec + fork syscalls wrappers
// ------ File: unix-process.cpp -----------------------------------------------------------//
// Description: Shows hows to launch processes on Unix with Exec and Fork syscall wrappers.
//-------------------------------------------------------------------------------------------//
#include <iostream>
#include <vector>
// ----- Unix/Linux headers -----//
#include <unistd.h>
#include <sys/types.h>
@caiorss
caiorss / unix-low-level-io.cpp
Created June 19, 2020 23:08
Unix low level IO - file descriptor syscalls
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cstring> // Import: char* strerror(in errnum);
const char*
@caiorss
caiorss / CMakeLists.txt
Last active December 12, 2023 05:39
Parse metadata from Windows PE files (PE32, PE64) executables and dll's
cmake_minimum_required(VERSION 3.9)
project(pe-metadata)
#========== Global Configurations =============#
#----------------------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_executable(pe-info pe-info.cpp pe_data.hpp)
@caiorss
caiorss / CMakeLists.txt
Created June 17, 2019 03:09
C++ project with Tinyxml2 library and CMake + Conan package manager - https://caiorss.github.io/C-Cpp-Notes/index.html
cmake_minimum_required(VERSION 3.9)
project(tinyxml2-test)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
#=========== Conan Bootstrap =================#
# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
@caiorss
caiorss / CMakeLists.txt
Created June 16, 2019 00:14
Cmake conan C++ project example
cmake_minimum_required(VERSION 3.9)
#========== Global Configurations =============#
#----------------------------------------------#
project(ConanTesting CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
# ============= Conan Bootstrap =============================#
@caiorss
caiorss / CMakeLists.txt
Created May 24, 2019 03:58
Example - Calling C++ from C
cmake_minimum_required(VERSION 3.9)
project( CallCppFromC)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_executable(main main.c codecpp.cpp codecpp.hpp)
@caiorss
caiorss / .gitignore
Last active May 22, 2019 17:35
Example - sample project with CMake and Google Test Gtest
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
/.vs