Skip to content

Commit

Permalink
Testing cmake support in vs2017
Browse files Browse the repository at this point in the history
  • Loading branch information
playmer committed Mar 31, 2017
1 parent efe6ccc commit 274cbe6
Show file tree
Hide file tree
Showing 34 changed files with 4,207 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cmaketest/CMake/AddFile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
################################################################################
# Project: YTE Engine
# Legal : All content � 2013-2014 DigiPen (USA) Corporation, all rights reserved.
# Author : Joshua T. Fisher (2014)
# About : A script for getting the subdirectory of a folder. (From Stack Overflow.)
# Usage : cmake -E PrintVersion.cmake
################################################################################
Include(${Source_Root}/cmake/Precompiled.cmake)

Macro(EngineSystemSetup engineSystem)
File( GLOB_RECURSE EngineSystemSource *.cpp *.c)
File( GLOB_RECURSE EngineSystemHeaders *.hpp *.h)

EngineSystemSetupDirectory(${engineSystem} ${CMAKE_CURRENT_SOURCE_DIR}
"${EngineSystemSource}" "${EngineSystemHeaders}")
EndMacro()

Function(EngineSystemSetupDirectory engineSystem currentDirectory sourceFiles headerFiles)
Include_Directories(${currentDirectory} ${Engine_System_Root})

# Make source groups
SourceGroupSetup(${currentDirectory} " " FALSE)

File( GLOB precompiledFile pch.c*)
List( REMOVE_ITEM sourceFiles ${precompiledFile})

SetPrecompiledHeader(pch.h ${precompiledFile} sourceFiles)
Add_Library( ${engineSystem} ${sourceFiles} ${headerFiles})


If (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Target_Compile_Options(${engineSystem} PUBLIC "/MT$<$<CONFIG:Debug>:d>")
EndIf()

# External Dependencies
Target_Link_Libraries(${engineSystem} ${LIBCMT_LIBRARIES} ${StaticLibraries})

set_property( TARGET ${engineSystem} PROPERTY FOLDER "YTE")
EndFunction()


Macro(AddFile aSource aPreviousSource aFileName)
Get_Filename_Component(DirectoryName ${CMAKE_CURRENT_SOURCE_DIR} NAME)

Set(${aPreviousSource} ${${aPreviousSource}} ${DirectoryName}/${aFileName})
EndMacro()
71 changes: 71 additions & 0 deletions cmaketest/CMake/FindDependency.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
################################################################################
# Project: YTE Engine
# File : CMakeLists.txt
# Legal : All content � 2013-2014 DigiPen (USA) Corporation, all rights reserved.
# Author : Joshua T. Fisher (2014)
# About : A script for getting the subdirectory of a folder. (From Stack Overflow.)
# Usage : cmake -E PrintVersion.cmake
################################################################################
include(${Source_Root}/cmake/ListChildren.cmake)

Macro(FindDependency DependencyName StaticLibraries SharedLibraries SharedLibrariesRelative IncludeDirectory)
Set(IndividualDependencyPath ${DependencyPath}/${DependencyName})


Message(STATUS ${DependencyName})
File( GLOB_RECURSE
StaticLibraryFiles
${IndividualDependencyPath}/library/${DependencyPlatform}
${IndividualDependencyPath}/library/${DependencyPlatform}/*.lib)

File( GLOB_RECURSE
SharedLibraryFiles
${IndividualDependencyPath}/library/${DependencyPlatform}
${IndividualDependencyPath}/library/${DependencyPlatform}/*.dll)

File( GLOB_RECURSE
SharedLibraryFilesRelative
RELATIVE
${IndividualDependencyPath}/library/${DependencyPlatform}
${IndividualDependencyPath}/library/${DependencyPlatform}/*.dll)

Set(${StaticLibraries} ${StaticLibraryFiles})
Set(${SharedLibraries} ${SharedLibraryFiles})
Set(${SharedLibrariesRelative} ${SharedLibraryFilesRelative})
Set(${IncludeDirectory} ${IndividualDependencyPath}/include)
EndMacro()


Macro(FindDependencyStatic DependencyName StaticLibrariesRelease StaticLibrariesDebug
SharedLibraries SharedLibrariesRelative IncludeDirectory)
Set(IndividualDependencyPath ${DependencyPath}/${DependencyName})


Message(STATUS ${DependencyName})
File( GLOB_RECURSE
StaticLibraryReleaseFiles
${IndividualDependencyPath}/library/${DependencyPlatform}/Release
${IndividualDependencyPath}/library/${DependencyPlatform}/Release/*.lib)

File( GLOB_RECURSE
StaticLibraryDebugFiles
${IndividualDependencyPath}/library/${DependencyPlatform}/Debug
${IndividualDependencyPath}/library/${DependencyPlatform}/Debug/*.lib)

File( GLOB_RECURSE
SharedLibraryFiles
${IndividualDependencyPath}/library/${DependencyPlatform}
${IndividualDependencyPath}/library/${DependencyPlatform}/*.dll)

File( GLOB_RECURSE
SharedLibraryFilesRelative
RELATIVE
${IndividualDependencyPath}/library/${DependencyPlatform}
${IndividualDependencyPath}/library/${DependencyPlatform}/*.dll)

Set(${StaticLibrariesRelease} ${StaticLibraryReleaseFiles})
Set(${StaticLibrariesDebug} ${StaticLibraryDebugFiles})
Set(${SharedLibraries} ${SharedLibraryFiles})
Set(${SharedLibrariesRelative} ${SharedLibraryFilesRelative})
Set(${IncludeDirectory} ${IndividualDependencyPath}/include)
EndMacro()
34 changes: 34 additions & 0 deletions cmaketest/CMake/ListChildren.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
################################################################################
# Project: YTE Engine
# File : CMakeLists.txt
# Legal : All content © 2013-2014 DigiPen (USA) Corporation, all rights reserved.
# Author : Joshua T. Fisher (2014)
# About : A script for getting the subdirectory of a folder. (From Stack Overflow.)
################################################################################
MACRO(ListDirectories result currentDirectory)
File(GLOB children RELATIVE ${currentDirectory} ${currentDirectory}/*)
Set(dirlist "")

ForEach(child ${children})
If(IS_DIRECTORY ${currentDirectory}/${child})
List(APPEND dirlist ${child})
EndIf()
EndForEach()

Set(${result} ${dirlist})
ENDMACRO()

MACRO(ListFiles result currentDirectory)
File(GLOB children ${currentDirectory}
${currentDirectory}/*.cpp ${currentDirectory}/*.c
${currentDirectory}/*.hpp ${currentDirectory}/*.h)
Set(dirlist "")

ForEach(child ${children})
If(NOT IS_DIRECTORY ${currentDirectory}/${child})
List(APPEND dirlist ${child})
EndIf()
EndForEach()

Set(${result} ${dirlist})
ENDMACRO()
74 changes: 74 additions & 0 deletions cmaketest/CMake/Moc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
################################################################################
# Project: YTE Engine
# Legal : All content ? 2013-2014 DigiPen (USA) Corporation, all rights reserved.
# Author : Joshua T. Fisher (2014)
# About : A script for getting the subdirectory of a folder. (From Stack Overflow.)
################################################################################
Macro(MocHeadersResult result currentDirectory)
File( GLOB_RECURSE sourceFiles *.hpp *.h )

Set(resultList "")

ForEach(sourceFile ${sourceFiles})
Get_Filename_Component(fileName ${sourceFile} NAME_WE)

List(APPEND resultList ${currentDirectory}/moc_${fileName}.cpp)

File(WRITE ${currentDirectory}/moc_${fileName}.cpp "//File intentionally left blank.")
EndForEach()

Set(${result} ${resultList})
EndMacro()

Macro(MocHeaders currentDirectory outDirectory target)
Set(MocExe ${Source_Root}/Dependencies/Qt/binary/moc.exe)

File( GLOB_RECURSE sourceFiles *.hpp *.h )

ForEach(sourceFile ${sourceFiles})
Get_Filename_Component(fileName ${sourceFile} NAME_WE)

Add_Custom_Command(TARGET ${target}
PRE_BUILD
COMMAND ${MocExe}
ARGS ${sourceFile}
-o ${outDirectory}/moc_${fileName}.cpp)
EndForEach()
EndMacro()

Macro(MocImplementationResult result currentDirectory)
File( GLOB_RECURSE sourceFiles *.cpp *.c )

Set(resultList "")

ForEach( sourceFile ${sourceFiles} )
Get_Filename_Component(fileName ${sourceFile} NAME_WE)

List(APPEND resultList ${currentDirectory}/${fileName}.moc)

File(WRITE ${currentDirectory}/${fileName}.moc "//File intentionally left blank.")
EndForEach()

Set(${result} ${resultList})
EndMacro()

Macro(MocImplementation currentDirectory outDirectory target)
Set( MocExe ${Source_Root}/Dependencies/Qt/binary/moc.exe )

File( GLOB_RECURSE sourceFiles *.cpp *.c )

ForEach( sourceFile ${sourceFiles} )
Get_Filename_Component(fileName ${sourceFile} NAME_WE)

Add_Custom_Command(TARGET ${target}
PRE_BUILD
COMMAND ${MocExe}
ARGS ${sourceFile}
-o ${outDirectory}/${fileName}.moc)
EndForEach()
EndMacro()

Macro(Moc currentDirectory outDirectory target)
MocImplementation(${currentDirectory} ${outDirectory} ${target})
MocHeaders(${currentDirectory} ${outDirectory} ${target})
EndMacro()
30 changes: 30 additions & 0 deletions cmaketest/CMake/Precompiled.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
################################################################################
# Project: RG3D Engine
# File : CMakeLists.txt
# Legal : All content © 2013-2014 DigiPen (USA) Corporation, all rights reserved.
# Author : Trent Reed (2013)
# About : A script for printing the current source number.
# Usage : cmake -E PrintVersion.cmake
################################################################################
Macro(SetPrecompiledHeader precompiledHeader precompiledSource sourceFiles)
if(MSVC AND ${Analysis})
Get_Filename_Component(pchheaderBasename ${precompiledHeader} NAME_WE)
Set(precompiledBinary "$(IntDir)${pchheaderBasename}.pch")
Set(source ${${sourceFiles}})

Set_Source_Files_Properties(${precompiledSource}
PROPERTIES
COMPILE_FLAGS
"/Yc\"\"${precompiledHeader}\"\" /Fp\"${precompiledBinary}\""
OBJECT_OUTPUTS
"${precompiledBinary}")
Set_Source_Files_Properties(${source}
PROPERTIES
COMPILE_FLAGS
"/Yu\"${precompiledHeader}\" /FI\"${precompiledHeader}\" /Fp\"${precompiledBinary}\""
OBJECT_DEPENDS
"${precompiledBinary}")
# Add precompiled header to SourcesVar
list(APPEND ${sourceFiles} ${precompiledSource})
endif()
EndMacro()
25 changes: 25 additions & 0 deletions cmaketest/CMake/SourceGroupSetup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
################################################################################
# Project: YTE Engine
# Legal : All content � 2013-2014 DigiPen (USA) Corporation, all rights reserved.
# Author : Joshua T. Fisher (2014)
# About : A script for getting the subdirectories of a folder.
# (From Stack Overflow.)
################################################################################
Function(SourceGroupSetup currentDirectory currentSourceGroup recursed)
ListDirectories( subDirectories ${currentDirectory} )
ListFiles( subFiles ${currentDirectory} )

ForEach(subDirectory ${subDirectories})
If (currentSourceGroup STREQUAL " ")
SourceGroupSetup("${currentDirectory}/${subDirectory}" "${subDirectory}" TRUE)
Else()
SourceGroupSetup("${currentDirectory}/${subDirectory}" "${currentSourceGroup}\\${subDirectory}" TRUE)
EndIf()
EndForEach()

If (recursed)
Source_Group(${currentSourceGroup} FILES ${subFiles})
Else()
Source_Group(" " FILES ${subFiles})
EndIf()
EndFunction()
98 changes: 98 additions & 0 deletions cmaketest/CMake/modules/FindFMODStudio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
FIND_PATH(FMOD_INCLUDE_DIR fmod_studio.h
HINTS
$ENV{FMOD_INC}
PATH_SUFFIXES include/FMOD include FMOD
i686-w64-mingw32/include/FMOD
x86_64-w64-mingw32/include/FMOD
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/include/FMOD
/usr/include/FMOD
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)

FIND_LIBRARY(FMOD_STUDIO_LIBRARY_TEMP
NAMES
fmodstudioL64.so fmodstudioL64.dll
HINTS
$ENV{FMOD}
PATH_SUFFIXES lib64 lib
lib/x64
x86_64-w64-mingw32/lib
PATHS
/usr/local/lib/FMOD
/sw
/opt/local
/opt/csw
/opt
)



FIND_LIBRARY(FMOD_LIBRARY_TEMP
NAMES
fmodL64.so fmodL64.dll
HINTS
$ENV{FMOD}
PATH_SUFFIXES lib64 lib
lib/x64
x86_64-w64-mingw32/lib
PATHS
/usr/local/lib/FMOD
/sw
/opt/local
/opt/csw
/opt
)

if (${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 2013 Win64" OR
${CMAKE_GENERATOR} STREQUAL "Visual Studio 14 Win64")
set(FMOD_STUDIO_LIBRARY_TEMP "${SOURCE_ROOT}/dep/lib/x64/fmodstudioL64_vc.lib")
set(FMOD_LIBRARY_TEMP "${SOURCE_ROOT}/dep/lib/x64/fmodL64_vc.lib")
elseif (${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 2013" OR
${CMAKE_GENERATOR} STREQUAL "Visual Studio 14")
set(FMOD_STUDIO_LIBRARY_TEMP "${SOURCE_ROOT}/dep/lib/x86/fmodstudioL_vc.lib")
set(FMOD_LIBRARY_TEMP "${SOURCE_ROOT}/dep/lib/x86/fmodL_vc.lib")
endif()

# MinGW needs an additional library, mwindows
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
# (Actually on second look, I think it only needs one of the m* libraries.)
IF(MINGW)
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
ENDIF(MINGW)

SET(FMOD_FOUND "NO")

IF(FMOD_LIBRARY_TEMP AND FMOD_STUDIO_LIBRARY_TEMP)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(FMOD_LIBRARY_TEMP ${FMOD_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)

# For MinGW library
IF(MINGW)
SET(FMOD_LIBRARY_TEMP ${MINGW32_LIBRARY} ${FMOD_LIBRARY_TEMP})
ENDIF(MINGW)

# Set the final string here so the GUI reflects the final state.
SET(FMOD_LIBRARY ${FMOD_LIBRARY_TEMP} CACHE STRING "Where the FMOD Library can be found")
SET(FMOD_STUDIO_LIBRARY ${FMOD_STUDIO_LIBRARY_TEMP} CACHE STRING "Where the FMOD Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(FMOD_LIBRARY_TEMP "${FMOD_LIBRARY_TEMP}" CACHE INTERNAL "")

SET(FMOD_FOUND "YES")
ENDIF(FMOD_LIBRARY_TEMP AND FMOD_STUDIO_LIBRARY_TEMP)

INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(FMOD REQUIRED_VARS FMOD_LIBRARY FMOD_INCLUDE_DIR)
Loading

0 comments on commit 274cbe6

Please sign in to comment.