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

Fixed Building on Windows (finally) #132

Closed
wants to merge 1 commit into from

Conversation

Quaker762
Copy link
Member

It is now actually possible to compile on Windows using cmake instead of having to rely on an IDE environment. An icon for the test programs was also added to differentiate it from the actual (sh3r.exe) program.

@Quaker762
Copy link
Member Author

It was an absolute pain in the arse to get this to work correctly... Luckily it should work 100%, though it relies on a path passed in from build.bat, which is the only way I could think to do this without any centralized package location.

It is now actually possible to compile on Windows using cmake instead of
having to rely on an IDE environment. An icon for the test programs was
also added to differentiate it from the actual (sh3r.exe) program.
@@ -20,7 +24,7 @@ endif()

include(CheckCXXCompilerFlag)

if(NOT CMAKE_BUILD_TYPE)
if(NOT CMAKE_BUIiLD_TYPE)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change can't be right.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was definitely using VIM or something when I did this hahaha.

if(WIN32)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # We're dealing with MinGW etc
set(Boost_USE_STATIC_LIBS ON)
set(BOOST_INCLUDEDIR ${LIB_ROOT_DIR}/boost/boost)
Copy link
Collaborator

Choose a reason for hiding this comment

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

LIB_ROOT_DIR should be a documented CMake variable that appears in the configurator (.e.g cmake-gui or ccmake).

Copy link
Member Author

@Quaker762 Quaker762 Apr 9, 2018

Choose a reason for hiding this comment

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

I've passed it in with -D in the .bat file, does that not create the variable? It needs to be a defined CMake one? I apologise for this, I couldn't find much info on it online.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It'll work, yeah, but when you define it with set (doc) you can document it and it will show up in the interactive CMake dialogs.


set(GLEW_LIBRARY ${LIB_ROOT_DIR}/GLEW/lib/libglew.a)
set(SDL2_LIBRARY ${LIB_ROOT_DIR}/SDL2/lib)
set(ZLIB_LIBRARY ${LIB_ROOT_DIR}/zlib/lib/zlib.a)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it suffice to set GLEW_ROOT_DIR & friends so that the libraries' CMake-configuration files search the path?
At this point LIB_ROOT_DIR might become the same as CMAKE_PREFIX_PATH. Perhaps try setting this to your "lib"-directory on Windows.

Copy link
Member Author

Choose a reason for hiding this comment

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

At this point LIB_ROOT_DIR might become the same as CMAKE_PREFIX_PATH. Perhaps try setting this to your "lib"-directory on Windows.

I think this might be the correct way to go.


set(GLEW_LIBRARIES ${LIB_ROOT_DIR}/GLEW/lib/libglew.a)
set(SDL2_INCLUDE_DIRS ${LIB_ROOT_DIR}/SDL2/include/SDL2) # CMake doesn't automatically pass this like the others???
set(CMAKE_EXE_LINKER_FLAGS "-lmingw32")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does GCC on Windows imply MinGW? What about Cygwin?

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume so, but I'll need to double check. Considering they're both built off of GCC.

set(ZLIB_LIBRARY ${LIB_ROOT_DIR}/zlib/lib/zlib.a)

set(GLEW_LIBRARIES ${LIB_ROOT_DIR}/GLEW/lib/libglew.a)
set(SDL2_INCLUDE_DIRS ${LIB_ROOT_DIR}/SDL2/include/SDL2) # CMake doesn't automatically pass this like the others???
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you might be referring to the SDL2_INCLUDE_DIR in your batch file, which might just be missing an S.

@z33ky
Copy link
Collaborator

z33ky commented Apr 4, 2018

Also I've used tabs in the CMake files.

@Quaker762
Copy link
Member Author

Also I've used tabs in the CMake files.

Goddamn.. I'll get on this in the next few days. I've got 3 assignments due this week. Kill me.

@Quaker762
Copy link
Member Author

This is 110% deprecated now :3

@Quaker762 Quaker762 closed this Jan 28, 2019
@Quaker762 Quaker762 deleted the cmake_win branch January 30, 2019 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants