Skip to content

Update CMakeLists.txt mainly for MSVC #344

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

Closed
wants to merge 1 commit into from

Conversation

yosagi
Copy link

@yosagi yosagi commented Nov 6, 2019

  1. Modify compiler flags for MSVC.
  2. Change output path and library name to cmake default.
  3. Avoid building entire binding codes on re-configure.
  4. api.json can be generated with specified godot executable (optional)

With this CMakeLists.txt, godot-cpp repository should be used as a part of user code project, and the user code should be linked with a cmake target ''godot-cpp''.

See sample use case: https://github.com/yosagi/godot-cpp-cmake

My environment:
VC2017
VC2019
CMake 3.14.5

@BastiaanOlij
Copy link
Collaborator

@underdoeg , @Acclution if either of you is still testing the cmake build, can you comment if this works properly?

@BastiaanOlij BastiaanOlij added the enhancement This is an enhancement on the current functionality label Jan 30, 2020
@underdoeg
Copy link
Contributor

I still rely on cmake when using gdnative on linux. on first glance this looks ok. but I dont have the time right now to actually test it. but if it were up to me, feel free to merge and I would issue a new pull request with fixes for linux if necessary.

@Acclution
Copy link
Contributor

I am at work now with a windows pc and it built a lib file correctly. Though can not test against any game code. CMake generated godot-cpp.lib file (I guess it will be libgodot-cpp.a/so on linux) instead of "godot.os.build_type.system_bits". I do not remeber what the scons file name is. You can deside if this is ok.

Was there a reason for removing /MD and /O2 flag? I have not tested mush agains windows myself so I have no idea if it is needed. Does the scons version have the MD or O2 flag?

@yosagi
Copy link
Author

yosagi commented Feb 4, 2020

I Think CMake will choose proper option depending on a build type like /MD or /MDd and /O2. We don't need explicit definition of such options. If we do need override default ones, we need to set variables such as CMAKE_CXX_FLAGS_. On my PC, CMake set these variables as follows.

//Flags used by the CXX compiler during all build types.
CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc

//Flags used by the CXX compiler during DEBUG builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1

//Flags used by the CXX compiler during MINSIZEREL builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG

//Flags used by the CXX compiler during RELEASE builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG

//Flags used by the CXX compiler during RELWITHDEBINFO builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG

Also, Visual studio generators generates a solution file includes all build type. Matching with CMAKE_BUILD_TYPE will not work with such generators.

@Zylann Zylann added the cmake label Jan 31, 2021
@vnen
Copy link
Member

vnen commented Mar 1, 2021

I don't use CMake so I'll give to you people to sort this one out. It needs a rebase to fix the conflicts.

@akien-mga akien-mga added the topic:buildsystem Related to the buildsystem or CI setup label Sep 27, 2021
@akien-mga akien-mga added this to the 4.0 milestone Sep 27, 2021
@aaronfranke aaronfranke modified the milestones: 4.0, 4.x Jul 8, 2023
@aaronfranke
Copy link
Member

Is this still relevant for Godot 4.x and GDExtension? If so, it needs a rebase before it can be considered.

@Torets
Copy link

Torets commented Sep 12, 2023

this is still relevant. I've created issue, that describes at least one problem, mentioned here
#1229

@enetheru
Copy link
Collaborator

Everything in this PR, except the option to generate the binding files from an executable, is now redundant from other PR's

@aaronfranke aaronfranke removed this from the 4.x milestone Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived cmake enhancement This is an enhancement on the current functionality topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants