Skip to content

Commit

Permalink
Cmake setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sim15 committed Feb 3, 2024
1 parent 1bc4b46 commit 2e00007
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 8 deletions.
76 changes: 76 additions & 0 deletions CMakelists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.14)
project(leaf)

# set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)

# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(TEST_DIR
tests
)

set(SOURCE_DIR
src
)

set(SOURCE
${SOURCE_DIR}/main.cpp
)

project(${PROJECT_NAME})

# ########
# GTest
# ########
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/e49c6b946a44f9a58586bfc76f75687d8f77e725.zip
)

# # For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)


# ##########
# Project
# ##########
# add_executable(${PROJECT_NAME} ${SOURCE})
include_directories(${PROJECT_SOURCE_DIR}/src)

set(SOURCE_FILES
${CMAKE_SOURCE_DIR}/${SOURCE_DIR}/constants.hpp
${CMAKE_SOURCE_DIR}/${SOURCE_DIR}/flametree.hpp
${CMAKE_SOURCE_DIR}/${SOURCE_DIR}/leaffunction.hpp
${CMAKE_SOURCE_DIR}/${SOURCE_DIR}/profiler.hpp
${CMAKE_SOURCE_DIR}/${SOURCE_DIR}/rapl.hpp
)

add_executable(${PROJECT_NAME} "${SOURCE_FILES}")


# #########################
# TESTING
# #########################
enable_testing()

set(TEST_FILES
${TEST_DIR}/test.cpp
)

add_executable(
profiler_test
"${TEST_FILES}"
)

target_link_libraries(
profiler_test
GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(profiler_test)

2 changes: 2 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
9 changes: 9 additions & 0 deletions tests/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}
8 changes: 0 additions & 8 deletions tests/test_read_rapl.c

This file was deleted.

0 comments on commit 2e00007

Please sign in to comment.