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

Feature: Enhanced CMake Build Script #12

Merged
merged 1 commit into from
Oct 19, 2019
Merged

Conversation

guestnone
Copy link
Contributor

@guestnone guestnone commented Oct 11, 2019

This extends and refactors the original CMake script to make it nicer.
The structure of it is loosely based on that used in bs::framework project.

  • Separate the Main SDK build definitions to its own CMakeLists.txt.
    Source file lists for each project were also moved to file CMakeSources.cmake,
    cataloged based on a folder they're in and the filter definitions for VS were added.
  • During build the executable/library artifacts are now stored in
    <BUILD_DIR>/<BIN_OR_LIB>/<ARCHITECTURE>/<BUILD_TYPE>. The scripts were
    modified to reflect that change.
  • Added most of the build flags from the original VS project
    with some new ones.
  • Added some properties to explicitly configure the build environment.
  • Add ability to install the libraries for distribution.
  • Other small renaming, cleanups and things that I've forgotten.

Copy link
Contributor

@ksmit799 ksmit799 left a comment

Choose a reason for hiding this comment

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

Overall, looks pretty good. Just a couple of concerns with some re-definitions, etc.

CMakeLists.txt Outdated
# What do we want to build?
option(GGPO_BUILD_SDK "Enable the build of the GGPO SDK" ON)
option(GGPO_BUILD_VECTORWAR "Enable the build of the Vector War example app" ON)
option(GGPO_BUILD_SHARED_LIBS "Enable the build of shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we need to use a re-definition of BUILD_SHARED_LIBS? It means we have to explicitly state the library type when calling add_library().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I didn't know that BUILD_SHARED_LIBS was a built-it option and I wanted to be more explicit (and it was late when I was finishing this). Will change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Now BUILD_SHARED_LIBS just inherits the GGPO_BUILD_SHARED_LIBS value. I've also reverted the changes to the add_library and BUILD_SHARED_LIBS stuff to what was before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just remove GGPO_BUILD_SHARED_LIBS altogether? Seeing as BUILD_SHARED_LIBS is builtin, having the two options linked together could be confusing, especially if one is set explicitly on the cli making them out of sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wanted to make the naming uniform with the other options, but I can understand the concern. Change reverted.

if(MSVC)
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/DEBUG /INCREMENTAL")
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE "/DEBUG /LTCG /INCREMENTAL:NO /OPT:REF")
set_property(TARGET ${target} APPEND PROPERTY COMPILE_OPTIONS -DWIN32 -D_WINDOWS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
Copy link
Contributor

Choose a reason for hiding this comment

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

I was planning on leaving the warnings in and fixing them later down the road, but I guess that's up to @pond3r

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing them would be nice. We had to disable the "use safe C library functions" warnings explicitly within the code at my company, since they can be such an annoyance with third party code (and last time I've checked they were only implemented by MSVC, C11 seems to provide them, but IDK about the compiler/C library support). But I'm also will leave the decision up to Tony.

Copy link
Owner

Choose a reason for hiding this comment

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

I think the right path here is to eventually fix all the warnings and remove the defines which explicitly ignore them so the code just builds clean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Removed -D_WINSOCK_DEPRECATED_NO_WARNINGS and -D_CRT_SECURE_NO_WARNINGS from the compile options.


## GGPO uses C-with-classes C++ flavour, so technically it should compile with C++03
## but to be more safe, we set the standard to C++11
set(CMAKE_CXX_STANDARD 11)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see no problem with modernising the codebase somewhat (and bringing up the cpp standard). However, I know Tony has expressed concerns with bringing in the STL so this is a discussion that we should probably have at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can understand. STL while convenient, does add some bloat. I just set it to C++11 to be more on the safe side, but I will try to lower it down to C++03.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the set C++ standard to C++98 (CMake doesn't define C++03, but GGPO compiles fine with C++98).

@guestnone guestnone force-pushed the dev/cmake branch 2 times, most recently from 37a4393 to 04f76dc Compare October 12, 2019 14:54
This extends and refactors the original CMake script to make it nicer.
The structure of it is loosely based on that used in bs::framework project.

- Separate the Main SDK build definitions to its own CMakeLists.txt.
  Source file lists for each project were also moved to file CMakeSources.cmake,
  cataloged based on a folder they're in and the filter definitions for VS were added.
- During build the executable/library artifacts are now stored in
  <BUILD_DIR>/<BIN_OR_LIB>/<ARCHITECTURE>/<BUILD_TYPE>. The scripts were
  modified to reflect that change.
- Added most of the build flags from the original VS project
  with some new one.
- Added some properties to explicitly configure the build environment.
- Add ability to install the libraries for distribution.
- Other small renaming, cleanups and things that I've forgotten.
@pond3r
Copy link
Owner

pond3r commented Oct 19, 2019

Sorry for the delay, friends. I've been super tanked at work! LGTM.

@pond3r pond3r merged commit 5f4ca6b into pond3r:master Oct 19, 2019
james7132 referenced this pull request in HouraiTeahouse/Backroll May 27, 2020
Feature: Enhanced CMake Build Script
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