Skip to content

Commit

Permalink
Project update (#4)
Browse files Browse the repository at this point in the history
* Add CMake support
* Remove old project files
* Add linter support
* Add dynamic building for googletest
  • Loading branch information
michaeldoylecs authored May 28, 2018
1 parent 72ae0de commit bd5f7be
Show file tree
Hide file tree
Showing 366 changed files with 697 additions and 131,535 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*.userprefs

# Build results
build/*
!build/README.md
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
Expand All @@ -22,6 +24,9 @@ bld/
[Oo]bj/
[Ll]og/

# User development files
compile_commands.json

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down Expand Up @@ -258,4 +263,4 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
156 changes: 156 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Initial CMake configurations
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()

# CMakeLists for RocketAnalytics
cmake_minimum_required (VERSION 3.9)
project (
RocketAnalyticsLib
VERSION 0.2
DESCRIPTION "Rocket League replay parsing library"
)

set (CMAKE_CXX_STANDARD 17)
add_compile_options(-std=c++17)

# Google Testing Framework
# Download and unpack googletest at configure time
configure_file (CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download
)
if (result)
message (FATAL_ERROR "CMake step for googletest failed: ${result}")
endif ()
execute_process (COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download
)
if (result)
message (FATAL_ERROR "Build step for googletest failed: ${result}")
endif ()

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

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory (${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)

# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories ("${gtest_SOURCE_DIR}/include")
endif ()

# Compiler flags
# set (CMAKE_CXX_FLAGS
# "-std=c++14 -Wall -Wextra -Wpedantic -Wzero-as-null-pointer-constant"
# )

# Configure RocketAnalyticsLib Build
add_library (RocketAnalyticsLib
"RocketAnalyticsLib/src/BinaryReader.cpp"
"RocketAnalyticsLib/src/Byte.cpp"
"RocketAnalyticsLib/src/ReplayFile.cpp"
"RocketAnalyticsLib/src/ReplayFileReader.cpp"
"RocketAnalyticsLib/src/ReplayHeader.cpp"
"RocketAnalyticsLib/src/ReplayLevels.cpp"
"RocketAnalyticsLib/src/Version.cpp"
"RocketAnalyticsLib/src/properties/ByteValue.cpp"
"RocketAnalyticsLib/src/properties/Property.cpp"
"RocketAnalyticsLib/src/properties/PropertyType.cpp"
"RocketAnalyticsLib/src/properties/PropertyValue.cpp"
)

# TODO: Add public interface header
# RocketAnalyticsLib header files
target_include_directories (RocketAnalyticsLib
PRIVATE
${PROJECT_SOURCE_DIR}/RocketAnalyticsLib/include
${PROJECT_SOURCE_DIR}/RocketAnalyticsLib/include/properties
)

# RocketAnalyticsLib properties
set_target_properties (RocketAnalyticsLib PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD_REQUIRED 17
CXX_STANDARD_REQUIRED ON
)

# Configure Tests Build
add_executable (unitTests
"RocketAnalyticsTests/src/BinaryReaderTests.cpp"
"RocketAnalyticsTests/src/ByteTests.cpp"
"RocketAnalyticsTests/src/ReplayHeaderTests.cpp"
"RocketAnalyticsTests/src/RocketAnalyticsTests.cpp"
"RocketAnalyticsTests/src/VersionTests.cpp"
"RocketAnalyticsTests/src/properties/ByteValueTests.cpp"
"RocketAnalyticsTests/src/properties/PropertyTests.cpp"
"RocketAnalyticsTests/src/properties/PropertyTypeTests.cpp"
"RocketAnalyticsTests/src/properties/PropertyValueTests.cpp"
)

target_link_libraries (unitTests gtest gmock_main RocketAnalyticsLib)

# Tests header files
target_include_directories (unitTests
PRIVATE
${PROJECT_SOURCE_DIR}/RocketAnalyticsLib/include
${PROJECT_SOURCE_DIR}/RocketAnalyticsLib/include/properties
)

# Tests properties
set_target_properties (unitTests PROPERTIES
VERSION 0.1
CXX_STANDARD_REQUIRED 17
CXX_STANDARD_REQUIRED ON
)

enable_testing()
add_test (NAME unit_tests1 COMMAND unitTests)

# Look for clang-tidy
unset (CLANG_TIDY_EXECUTABLE)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy")
find_program (CLANG_TIDY_EXECUTABLE "clang-tidy"
DOC "Path to clang-tidy executable"
)
if (CLANG_TIDY_EXECUTABLE MATCHES "CLANG_TIDY_EXECUTABLE")
unset (CLANG_TIDY_EXECUTABLE)
message (WARNING "WARNING: .clang-tidy file found for \
project ${PROJECT_NAME}, yet clang-tidy not on PATH so disabling \
lint pass"
)
endif ()
endif ()

# Add clang-tidy to compilation if it exists
if (DEFINED CLANG_TIDY_EXECUTABLE)
if (MSVC)
# Tell clang-tidy to interpret these parameters as clang-cl would
set_target_properties (${PROJECT_NAME} PROPERTIES
CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE};-fms-extensions;\
-fms-compatibility-version=19;-D_M_AMD64=100;"
)
else()
set_target_properties (${PROJECT_NAME} PROPERTIES
CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE}
)
endif()
endif()

# Output location
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)

# Export compile_commands.json
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Compiling messages
message ("Compiling for: " ${CMAKE_BUILD_TYPE})
15 changes: 15 additions & 0 deletions CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8.2)

project(googletest-download NONE)

include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
139 changes: 0 additions & 139 deletions GTest/GTest.vcxproj

This file was deleted.

25 changes: 0 additions & 25 deletions GTest/GTest.vcxproj.filters

This file was deleted.

Loading

0 comments on commit bd5f7be

Please sign in to comment.