Skip to content

Commit

Permalink
CPM json and other minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GwGibson committed May 3, 2024
1 parent 3da6d94 commit ec3446c
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 26,199 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
# Install dependencies
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
doxygen graphviz ccache cppcheck libtbb-dev
doxygen graphviz ccache cppcheck libtbb-dev unzip python3.10-venv

# Install include-what-you-use
ENV IWYU /home/iwyu
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ venv/
ENV/
env.bak/
venv.bak/
psim_python/.venv

# Spyder project settings
.spyderproject
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ if(MSVC)
endif()

# For the "play" button in MSVC
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT psim.out)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT psim)

if(CMAKE_SKIP_INSTALL_RULES)
return()
endif()

include(cmake/PackageProject.cmake)

psim_package_project(TARGETS psim.out psim_options psim_warnings)
psim_package_project(TARGETS psim psim_options psim_warnings)

# Explicit package naming can help make it easier to sort
# out potential ABI related issues before they start, while helping you
Expand All @@ -79,7 +79,7 @@ set(CPACK_PACKAGE_FILE_NAME
)

include(InstallRequiredSystemLibraries)
install(TARGETS psim.out
install(TARGETS psim
RUNTIME DESTINATION bin)

set(CPACK_PACKAGE_NAME "psim")
Expand Down
39 changes: 31 additions & 8 deletions Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,36 @@ function(psim_setup_dependencies)
# cpmaddpackage("gh:CLIUtils/[email protected]")
# endif()

#if(NOT TARGET TBB::tbb)
# cpmaddpackage(
# NAME TBB
# VERSION 2021.10.0
# URL https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.10.0.tar.gz
# OPTIONS
# "TBB_TEST OFF")
#endif()
if(NOT TARGET nlohmann_json::nlohmann_json)
find_package(nlohmann_json QUIET)

if(NOT nlohmann_json_FOUND)
message(STATUS "nlohmann_json not found: Using CPM to fetch nlohmann_json")
CPMAddPackage(
NAME nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.10.4
)
set(nlohmann_json_INCLUDE_DIR "${nlohmann_json_SOURCE_DIR}/single_include" CACHE INTERNAL "")
endif()
endif()

if(NOT TARGET tbb)
find_package(TBB QUIET)

if(TBB_FOUND)
message(STATUS "Found TBB: Using system TBB")
else()
message(STATUS "TBB not found: Using CPM to fetch TBB")
CPMAddPackage(
NAME tbb
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
GIT_TAG v2021.11.0
OPTIONS
"TBB_TEST OFF"
"TBB_STRICT OFF"
)
endif()
endif()

endfunction()
2 changes: 1 addition & 1 deletion ProjectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ macro(psim_setup_options)

if(ENABLE_DEVELOPER_MODE)
option(psim_ENABLE_IPO "Enable IPO/LTO" OFF)
option(psim_WARNINGS_AS_ERRORS "Treat Warnings As Errors" ON)
option(psim_WARNINGS_AS_ERRORS "Treat Warnings As Errors" OFF)
option(psim_ENABLE_DOXYGEN "Build documentation with Doxygen" OFF)
option(psim_ENABLE_USER_LINKER "Enable user-selected linker" OFF)
option(psim_ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ See [tests](https://github.com/GwGibson/psim/actions/runs/5123185364) for workin

## Build Instructions

If you have all the necessary dependencies, you can run `make release` in the directory containing the `makefile`. The executable can then be found here: `build/psim/Release/psim.out`.
If you have all the necessary dependencies, you can run `make release` in the directory containing the `makefile`. The executable can then be found here: `build/psim/Release/psim`.

## Dependencies

Expand Down Expand Up @@ -120,7 +120,7 @@ make release
In the `python_sim` folder, there are 3 `.py` files. Running these files should produce the `.json` files in the `.json` folder. These are the files you can pass into the psim program. For example, if you put the `.json` files in the same directory as the psim executable, then you can run all five simulations using the command:

```bash
./psim.out *.json
./psim *.json
```

Some pre-built configurations can be found at `psim_python\psim\pre_builts.py`. This can give an idea of how to construct your systems, but this can be a complicated process depending on the intricacies of your desired configuration.
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build:
make release

release:
cmake -S ./ -B ./build -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE:STRING=Release
cmake -S ./ -B ./build -G "Ninja Multi-Config" -DENABLE_DEVELOPER_MODE:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build ./build --config Release

debug:
Expand Down
31 changes: 20 additions & 11 deletions psim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,42 @@ file(GLOB_RECURSE PSIM_SOURCES
)

set(module_name "psim")
add_library(${module_name} STATIC ${PSIM_SOURCES})
set(library_name "${module_name}_library") # Use module_name to generate library_name

file(GLOB_RECURSE PSIM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp" # Header files
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" # Source files
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" # Header files
)

add_library(${library_name} STATIC ${PSIM_SOURCES})

find_package(TBB QUIET)

if(TBB_FOUND)
target_link_libraries(${module_name} PRIVATE TBB::tbb)
target_link_libraries(${library_name} PRIVATE TBB::tbb)
else()
message(WARNING "TBB not found. Building without TBB support.")
endif()

target_link_libraries(
${module_name}
${library_name}
PUBLIC ${module_name}_options ${module_name}_warnings
)

target_include_directories(${module_name} PUBLIC
target_include_directories(${library_name} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_include_directories(${module_name} INTERFACE "${CMAKE_BINARY_DIR}/configured_files/include")

# Precompiled Headers
#target_precompile_headers(${module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/psimPch.h")
target_include_directories(${library_name} SYSTEM PUBLIC
"${nlohmann_json_INCLUDE_DIR}"
)

add_executable(${module_name}.out "./src/main.cpp")
target_include_directories(${library_name} INTERFACE "${CMAKE_BINARY_DIR}/configured_files/include")

add_executable(${module_name} "./src/main.cpp")
target_link_libraries(
${module_name}.out
PUBLIC ${module_name}
PRIVATE ${module_name}_options ${module_name}_warnings
${module_name}
PUBLIC ${library_name} ${module_name}_options ${module_name}_warnings nlohmann_json::nlohmann_json
)
Loading

0 comments on commit ec3446c

Please sign in to comment.