From 033c7577ceb086df25f25eb3e843652030263721 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 14 Jan 2022 16:32:31 +0100 Subject: [PATCH] Improve CMake and add instructions to README --- CMakeLists.txt | 12 +++++++++--- README.md | 15 +++++++++++++++ VTIL-Architecture/CMakeLists.txt | 4 +++- VTIL-Common/CMakeLists.txt | 4 +++- VTIL-Compiler/CMakeLists.txt | 4 +++- VTIL-SymEx/CMakeLists.txt | 4 +++- VTIL-Tests/CMakeLists.txt | 4 +++- VTIL/CMakeLists.txt | 4 +++- 8 files changed, 42 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 106f388..c87b62f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,16 @@ cmake_minimum_required(VERSION 3.14.5) # Define the VTIL project project(VTIL-Core) -option(VTIL_BUILD_TESTS "Build tests" OFF) +# Detect if VTIL-Core is compiled as the root project +set(VTIL_ROOT_PROJECT OFF) +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(VTIL_ROOT_PROJECT ON) -# Enable solution folder support -set_property(GLOBAL PROPERTY USE_FOLDERS ON) + # Enable solution folder support + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +endif() + +option(VTIL_BUILD_TESTS "Build tests" ${VTIL_ROOT_PROJECT}) # Load the dependencies set(CMAKE_FOLDER "VTIL-Core/Dependencies") diff --git a/README.md b/README.md index 888e76a..c464ee3 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,18 @@ This repository contains the core components of the VTIL Project used across the It is currently incomplete as the initial release is not done yet, and documentation and FAQ will be within this repository and the organization website once they're done. Until the initial release, you can keep up to date with the VTIL project by checking my [personal twitter account](https://twitter.com/_can1357) or the VTIL website [vtil.org](https://vtil.org/). + +## Building (Windows) + +``` +cmake -B build +``` + +Then open `build\VTIL-Core.sln`. You can also open this folder in a CMake-compatible IDE (Visual Studio, CLion, Qt Creator, VS Code). + +## Building (Linux/Mac) + +``` +cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build +``` diff --git a/VTIL-Architecture/CMakeLists.txt b/VTIL-Architecture/CMakeLists.txt index a884ea3..9207f67 100644 --- a/VTIL-Architecture/CMakeLists.txt +++ b/VTIL-Architecture/CMakeLists.txt @@ -1,4 +1,6 @@ -project(VTIL-Architecture) +# Extract project name from folder +get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +string(REPLACE " " "_" PROJECT_NAME "${PROJECT_NAME}") file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.cpp *.hpp) file(GLOB_RECURSE INCLUDES CONFIGURE_DEPENDS includes/*) diff --git a/VTIL-Common/CMakeLists.txt b/VTIL-Common/CMakeLists.txt index b4e6b28..46840f0 100644 --- a/VTIL-Common/CMakeLists.txt +++ b/VTIL-Common/CMakeLists.txt @@ -1,4 +1,6 @@ -project(VTIL-Common) +# Extract project name from folder +get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +string(REPLACE " " "_" PROJECT_NAME "${PROJECT_NAME}") file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.cpp *.hpp) file(GLOB_RECURSE INCLUDES CONFIGURE_DEPENDS includes/*) diff --git a/VTIL-Compiler/CMakeLists.txt b/VTIL-Compiler/CMakeLists.txt index a94e92b..07abbb3 100644 --- a/VTIL-Compiler/CMakeLists.txt +++ b/VTIL-Compiler/CMakeLists.txt @@ -1,4 +1,6 @@ -project(VTIL-Compiler) +# Extract project name from folder +get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +string(REPLACE " " "_" PROJECT_NAME "${PROJECT_NAME}") file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.cpp *.hpp) file(GLOB_RECURSE INCLUDES CONFIGURE_DEPENDS includes/*) diff --git a/VTIL-SymEx/CMakeLists.txt b/VTIL-SymEx/CMakeLists.txt index d2106db..b5da114 100644 --- a/VTIL-SymEx/CMakeLists.txt +++ b/VTIL-SymEx/CMakeLists.txt @@ -1,4 +1,6 @@ -project(VTIL-SymEx) +# Extract project name from folder +get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +string(REPLACE " " "_" PROJECT_NAME "${PROJECT_NAME}") file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.cpp *.hpp) file(GLOB_RECURSE INCLUDES CONFIGURE_DEPENDS includes/*) diff --git a/VTIL-Tests/CMakeLists.txt b/VTIL-Tests/CMakeLists.txt index de0b4e9..92cd82e 100644 --- a/VTIL-Tests/CMakeLists.txt +++ b/VTIL-Tests/CMakeLists.txt @@ -1,4 +1,6 @@ -project(VTIL-Tests) +# Extract project name from folder +get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +string(REPLACE " " "_" PROJECT_NAME "${PROJECT_NAME}") file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.cpp *.hpp *.h) diff --git a/VTIL/CMakeLists.txt b/VTIL/CMakeLists.txt index 25ba23f..b5f6b4f 100644 --- a/VTIL/CMakeLists.txt +++ b/VTIL/CMakeLists.txt @@ -1,4 +1,6 @@ -project(VTIL) +# Extract project name from folder +get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +string(REPLACE " " "_" PROJECT_NAME "${PROJECT_NAME}") # This builds no sources -- it simply aliases a collection of all other targets created by VTIL #