Skip to content

Commit 8ff873b

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # .github/workflows/ci_tests.yml
2 parents bbe7907 + 97c3d42 commit 8ff873b

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ project(
99

1010
set(CMAKE_CXX_STANDARD 20)
1111

12-
if(WIN32) # Install dlls in the same directory as the executable on Windows
12+
if (WIN32) # Install dlls in the same directory as the executable on Windows
1313
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
1414
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
1515
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
1616
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
1717
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
1818
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
19-
endif()
19+
endif ()
2020

2121
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
2222
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")
2323
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
2424
else ()
2525
set(CMAKE_CXX_FLAGS_DEBUG "-g")
2626
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
27-
endif()
27+
endif ()
2828

2929
add_subdirectory(lib)
3030
add_subdirectory(bin)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# C++ project template with Google Tests and CI/CD
22

33
This is a project template. Feel free to use & fork it. It contains all pre-configured
4-
CMakeLists.txt, so to use it, just replace project name with your in
4+
CMakeLists.txt, so to use it, replace project name with your one in
55
[main CmakeLists.txt](CMakeLists.txt), and all target and executable names in
66
[CI/CD script](./.github/workflows/ci_tests.yml). Sample program prints a greeting for the first argument.
77

88
## How to build and run
99

10-
Run following commands from project directory.
10+
Run the following commands from the project directory.
1111

1212
1. Create CMake cache
1313

1414
```shell
1515
cmake -S . -B cmake-build
1616
```
1717

18-
2. Build main target
18+
2. Build executable target
1919

2020
```shell
2121
cmake --build cmake-build --target cpp_tests
@@ -27,7 +27,7 @@ cmake --build cmake-build --target cpp_tests
2727
cmake --build cmake-build --target cpp_tests_tests
2828
```
2929

30-
4. Run main target
30+
4. Run executable target
3131

3232
* On Windows:
3333

bin/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
add_executable(${PROJECT_NAME} main.cpp)
22

3-
if(NOT CMAKE_BUILD_TYPE)
3+
if (NOT CMAKE_BUILD_TYPE)
44
set(CMAKE_BUILD_TYPE Release) # Main executable should be built with Release
5-
endif()
5+
endif ()
66

77
message(STATUS "Main executable build type: ${CMAKE_BUILD_TYPE}")
88

install.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,19 @@ if (cmake -S . -B "$CMAKE_PROJECT_DIR" -DCMAKE_BUILD_TYPE=Release -G "Unix Makef
6666

6767
exit 0
6868
elif (cd "$CMAKE_PROJECT_DIR" && "./$PROJECT_NAME$EXEC_EXTENSION" -h >/dev/null 2>/dev/null); then
69-
echo "Congratulations! $PROJECT_NAME was compiled successfully. But it is impossible to create a link to it - run it from $CMAKE_BUILD_DIR as .\\$PROJECT_NAME$EXEC_EXTENSION"
69+
rm -f "$EXEC_LINK_PATH"
70+
rm -rf "$HOME/${PROJECT_NAME:?}"
71+
echo "Congratulations! $PROJECT_NAME was compiled successfully."
72+
echo "Because of Windows-specific limitations, it is not possible to create a link to it."
73+
echo "You can run it from $HOME/$PROJECT_NAME as .\\$PROJECT_NAME$EXEC_EXTENSION"
74+
echo "Or you can run CMD.EXE with administrative privileges and type: "
75+
echo 'mklink "%userprofile%\weather-forecast.exe" "%userprofile%\weather-forecast\weather-forecast.exe"'
7076
echo ''
71-
cd "$CMAKE_PROJECT_DIR" && "./$PROJECT_NAME$EXEC_EXTENSION" -h
77+
mkdir "$HOME/$PROJECT_NAME"
78+
cp "$CMAKE_PROJECT_DIR/$PROJECT_NAME$EXEC_EXTENSION" "$HOME/$PROJECT_NAME/$PROJECT_NAME$EXEC_EXTENSION"
79+
# ALso copy all *dll files like following:
80+
# cp -r "$CMAKE_PROJECT_DIR/liblib.dll" "$HOME/$PROJECT_NAME/liblib.dll"
81+
cd "$HOME/$PROJECT_NAME" && "./$PROJECT_NAME$EXEC_EXTENSION" -h
7282
exit 0
7383
else
7484
echo 'Oops! Could not execute the program.'

lib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cmake_minimum_required(VERSION 3.12)
22

3-
if(NOT CMAKE_BUILD_TYPE)
3+
if (NOT CMAKE_BUILD_TYPE)
44
set(CMAKE_BUILD_TYPE Debug) # Change this to Release when you're ready to release
5-
endif()
5+
endif ()
66

77
message(STATUS "Libraries build type: ${CMAKE_BUILD_TYPE}")
88

tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(FetchContent)
33
FetchContent_Declare(
44
googletest
55
GIT_REPOSITORY https://github.com/google/googletest.git
6-
GIT_TAG release-1.12.1
6+
GIT_TAG v1.15.2
77
)
88

99
# For Windows: Prevent overriding the parent project's compiler/linker settings
@@ -29,9 +29,9 @@ target_link_libraries(
2929
GTest::gtest_main
3030
)
3131

32-
if(NOT CMAKE_BUILD_TYPE)
32+
if (NOT CMAKE_BUILD_TYPE)
3333
set(CMAKE_BUILD_TYPE Debug) # Tests should be built with Debug
34-
endif()
34+
endif ()
3535

3636
message(STATUS "Tests build type: ${CMAKE_BUILD_TYPE}")
3737

0 commit comments

Comments
 (0)