Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake basic #18

Open
wants to merge 15 commits into
base: cg-3k-3m-9
Choose a base branch
from
Open

Cmake basic #18

wants to merge 15 commits into from

Conversation

cheroy-ntia
Copy link
Collaborator

@cheroy-ntia cheroy-ntia commented Aug 14, 2024

  1. Add #pragma once for cross platform compiler
  2. Update define DLLEXPORT for non windows compliler
  3. Remove relative header file path in source code
  4. Add Additional Include Directories in win32 project config
  5. Add P528GTest google test project for win32.
  6. Add P528GTest source code and header files in /test/src for cmake
  7. Add generic test data csv in test/data
  8. Add test data tables in /test/Data Tables
  9. Add .gitmodules to clone google test and doxygen
  10. Add cmake folder for all cmake configurations and cmake README

No changes on repository folder structure for now.

@cheroy-ntia cheroy-ntia marked this pull request as ready for review August 15, 2024 20:36
Copy link

@blainNTIA blainNTIA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. I made a few suggestions. Please review them. I tested the cmake build on MacOS it worked well.

#include <string>
#include <functional>

class TestP528DataTables : public ::testing::TestWithParam<std::string>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a brief description of what tests are being preformed

To manually build the project, you can run the following commands step by step. As an example, we use /cmake_build as CMake build folder (cmake binary folder) and /if77install as installation folder.

```
mkdir cmake_build

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the cmake build a Mac and got three warnings. Please look at them and decide if they should be addressed or not.

[ 81%] Built target gtest_main
[ 84%] Building CXX object test/CMakeFiles/p528GTest.dir/p528/test/src/P528GTestUtils.cpp.o
/p528/test/src/P528GTestUtils.cpp:119:49: warning: implicit conversion of NULL constant to 'double' [-Wnull-conversion]
                    d.expectedResult.A_fs__db = NULL;
                                              ~ ^~~~
                                                0.0
1 warning generated.
[ 86%] Building CXX object test/CMakeFiles/p528GTest.dir/p528/test/src/TestP528.cpp.o
[ 88%] Building CXX object test/CMakeFiles/p528GTest.dir/p528/test/src/TestP528DataTables.cpp.o
/p528/test/src/TestP528DataTables.cpp:34:42: warning: comparison between NULL and non-pointer ('double' and NULL) [-Wnull-arithmetic]
        if (data.expectedResult.A_fs__db != NULL) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
/p528/test/src/TestP528DataTables.cpp:34:45: warning: implicit conversion of NULL constant to 'double' [-Wnull-conversion]
        if (data.expectedResult.A_fs__db != NULL) {
                                         ~~ ^~~~
                                            0.0
/p528/test/src/TestP528DataTables.cpp:41:1: warning: 'InstantiateTestCase_P_IsDeprecated' is deprecated: INSTANTIATE_TEST_CASE_P is deprecated, please use INSTANTIATE_TEST_SUITE_P [-Wdeprecated-declarations]
INSTANTIATE_TEST_CASE_P(
^
/p528/test/lib/googletest/googletest/include/gtest/gtest-param-test.h:539:38: note: expanded from macro 'INSTANTIATE_TEST_CASE_P'
  static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \
                                     ^
/p528/test/lib/googletest/googletest/include/gtest/internal/gtest-internal.h:1244:1: note: 'InstantiateTestCase_P_IsDeprecated' has been explicitly marked deprecated here
GTEST_INTERNAL_DEPRECATED(
^
/p528/test/lib/googletest/googletest/include/gtest/internal/gtest-port.h:2383:59: note: expanded from macro 'GTEST_INTERNAL_DEPRECATED'
#define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))
                                                          ^
3 warnings generated.
[ 90%] Linking CXX executable ../p528GTest

std::cout << "TestP528 from Data Table '" << fileName << "', " << testData.size() << " Test instances." << std::endl;
for (const auto& data : testData) {
Result result;
int rtn = P528(data.d__km, data.h_1__meter, data.h_2__meter, data.f__mhz, data.T_pol, data.p, &result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rtn is not used.

}
if (csvRows[1].size() > 2) {
//std::cout << csvRows[1][2] << std::endl;
for (int i = 2; i < csvRows[1].size(); i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using int here causes a mismatch between datatype of i and the value returned by csvRows[1].size() and the compiler complains when using the -Wall option. This can be avoided using the same type that is returned by the size() function. Its type is long so typedefing can help declutter the code. This issue also happens in other for loops in this file.

Suggested change
for (int i = 2; i < csvRows[1].size(); i++) {
typedef std::vector<std::vector<std::string> >::size_type vec_size_t
for (vec_size_t i = 2; i < csvRows[1].size(); i++) {

return ret;
}

std::vector<InputsAndResult> ReadP528InputsAndResultFromDataTable(const std::string& filename, int testStep) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment with a brief description of what the functions do.

Comment on lines 48 to 49
//std::cout << entry.path() << std::endl;
//std::string filename = entry.path().filename();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this dead code? If so, please remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants