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 Integration #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

CMake Integration #22

wants to merge 3 commits into from

Conversation

waqqas
Copy link

@waqqas waqqas commented Jan 14, 2020

Build NanoLog (cpp17) with cmake.

  • Added functionality to generate NanoLog.pc file, to easily integrate with other cmake based projects using PkgConfig package
  • Refactor: Moved unit test, decompressor and perf code to separate sub-directories
  • Refactor: Removed googletest as git sub-module. google-test can be installed using apt-get install googletest

Sample integration with cmake project

find_package(PkgConfig REQUIRED)
pkg_check_modules(NANOLOG REQUIRED NanoLog)
target_link_libraries(main ${NANOLOG_LDFLAGS})
target_include_directories(main PUBLIC ${NANOLOG_INCLUDE_DIRS})
target_compile_options(main PUBLIC ${NANOLOG_CFLAGS_OTHER})

TODO: move preprocessor version to cmake

…". Moved Perf in "perf" directory. Added CMakelist to generate library and decompressor. Added functionality to generate NanoLog.pc to easily integrate with other cmake projects using pkg-config
@waqqas waqqas mentioned this pull request Jan 14, 2020
@syang0
Copy link
Member

syang0 commented Jan 30, 2020

Hi waqqas,

 Thanks for the contribution 👍 .

Sorry for the late reply, I had to find the time to pull the patch and check it out. Some comments/fixes I'd like before I merge the patch are:

  1. Could you write a section in the README on how to compile the project with cmake and how to integrate it with other cmake projects that will use NanoLog as a library?
  2. Also for the README, I noticed that you removed the gtest submodule. Can you also conveniently include some instructions for newcomers on how to install/download gtest and point cmake towards it?
  3. It seems like cmake generates a whole bunch of files and folders that are not yet .gitignore'd. Could you add them to the .gitignore?

Some other notes I have are:

  1. Can you bring the integration tests or Preprocessor NanoLog into the cmake script?
  2. Your restructuring of the source directory breaks some of the GNUmakefile scripts. Can you fix them (if not I'll have to fix them before merging your patch)?

Best Regards,
Stephen Yang

file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/runtime/*.cc ${PROJECT_SOURCE_DIR}/runtime/testHelper/GeneratedCode.cc)
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})

target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/runtime)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be marked as PUBLIC not PRIVATE to ensure that non standalone builds get the correct include directories.

@andrewkcorcoran
Copy link
Contributor

We should support people consuming the library directly through CMake rather than through PkcConfig. https://cliutils.gitlab.io/modern-cmake/chapters/install.html

@andrewkcorcoran
Copy link
Contributor

I don't think removing the googletest submodule is the correct way to go. Requiring a manual installation of gtest is just added work and has potential for breaking changes if the user installs a version of gtest that has breaking changes to the one we ran our CI against. The existing solution of using submodules to refer to an exact commit ensures consistency between user experience and our CI builds.

find_package(RT REQUIRED)

file(GLOB HEADERS ${PROJECT_SOURCE_DIR}/runtime/*.h)
file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/runtime/*.cc ${PROJECT_SOURCE_DIR}/runtime/testHelper/GeneratedCode.cc)
Copy link
Contributor

Choose a reason for hiding this comment

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

GeneratedCode.cc is not a file that exists in the repo - it has to be generated by the preprocessor script. I don't think this command succeed on a standard check out. @syang0 do you have CI checks enabled on pull requests? I see no checks ran on this PR and I suspect they should be failing.

Copy link
Member

Choose a reason for hiding this comment

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

No, CI checks are only enabled on the main branch. They wouldn't have run anyway for this PR since it substantially changed the build structure and where the executables exist.

@andrewkcorcoran
Copy link
Contributor

andrewkcorcoran commented Feb 13, 2020 via email

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.

None yet

3 participants