Skip to content

Commit

Permalink
CMake: use PROJECT_*_DIR and remove superficial project() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Nov 10, 2018
1 parent 202076d commit 98563cb
Show file tree
Hide file tree
Showing 43 changed files with 398 additions and 422 deletions.
52 changes: 26 additions & 26 deletions CMake/ConfigureBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ if(SDL2_FOUND OR EMSCRIPTEN)
endif()

# generate OgreBuildSettings.h
configure_file(${OGRE_TEMPLATES_DIR}/OgreBuildSettings.h.in ${OGRE_BINARY_DIR}/include/OgreBuildSettings.h @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OgreRTShaderConfig.h.in ${OGRE_BINARY_DIR}/include/OgreRTShaderConfig.h @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OgreGLES2Config.h.in ${OGRE_BINARY_DIR}/include/OgreGLES2Config.h @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OgreBuildSettings.h.in ${PROJECT_BINARY_DIR}/include/OgreBuildSettings.h @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OgreRTShaderConfig.h.in ${PROJECT_BINARY_DIR}/include/OgreRTShaderConfig.h @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OgreGLES2Config.h.in ${PROJECT_BINARY_DIR}/include/OgreGLES2Config.h @ONLY)

set(OGRE_LIB_SUFFIX "")

Expand Down Expand Up @@ -174,68 +174,68 @@ if (UNIX)
endif ()
# there is no pkgconfig file for freeimage, so we need to add that lib manually
set(OGRE_ADDITIONAL_LIBS "${OGRE_ADDITIONAL_LIBS} -lfreeimage")
configure_file(${OGRE_TEMPLATES_DIR}/OGREStatic.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE.pc @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OGREStatic.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE.pc @ONLY)
else ()
configure_file(${OGRE_TEMPLATES_DIR}/OGRE.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE.pc @ONLY)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE.pc @ONLY)
endif ()
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)

# configure additional packages

if (OGRE_BUILD_PLUGIN_PCZ)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-PCZ.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-PCZ.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-PCZ.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-PCZ.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-PCZ.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-PCZ.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_PAGING)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Paging.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Paging.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Paging.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Paging.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Paging.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Paging.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_MESHLODGENERATOR)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-MeshLodGenerator.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-MeshLodGenerator.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-MeshLodGenerator.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-MeshLodGenerator.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-MeshLodGenerator.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-MeshLodGenerator.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_TERRAIN)
if (OGRE_BUILD_COMPONENT_PAGING)
set(OGRE_PAGING_ADDITIONAL_PACKAGES ", OGRE-Paging = ${OGRE_VERSION}")
endif ()
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Terrain.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Terrain.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Terrain.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Terrain.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Terrain.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Terrain.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_RTSHADERSYSTEM)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-RTShaderSystem.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-RTShaderSystem.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-RTShaderSystem.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-RTShaderSystem.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-RTShaderSystem.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-RTShaderSystem.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_PROPERTY)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Property.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Property.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Property.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Property.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Property.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Property.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_OVERLAY)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Overlay.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Overlay.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Overlay.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Overlay.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Overlay.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Overlay.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_VOLUME)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Volume.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Volume.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Volume.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Volume.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Volume.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Volume.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_BITES)
if (SDL2_FOUND)
set(OGRE_BITES_ADDITIONAL_PACKAGES ", sdl2")
endif ()
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Bites.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Bites.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-Bites.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-Bites.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Bites.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-Bites.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()

if (OGRE_BUILD_COMPONENT_HLMS)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-HLMS.pc.in ${OGRE_BINARY_DIR}/pkgconfig/OGRE-HLMS.pc @ONLY)
install(FILES ${OGRE_BINARY_DIR}/pkgconfig/OGRE-HLMS.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
configure_file(${OGRE_TEMPLATES_DIR}/OGRE-HLMS.pc.in ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-HLMS.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/pkgconfig/OGRE-HLMS.pc DESTINATION ${OGRE_LIB_DIRECTORY}/pkgconfig)
endif ()
endif ()

Expand Down
84 changes: 42 additions & 42 deletions CMake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,37 @@ if(OGRE_BUILD_PLATFORM_EMSCRIPTEN)
${OGRE_DEPENDENCIES_DIR}
${EMSCRIPTEN_ROOT_PATH}/system
${ENV_OGRE_DEPENDENCIES_DIR}
"${OGRE_BINARY_DIR}/EmscriptenDependencies"
"${OGRE_SOURCE_DIR}/EmscriptenDependencies"
"${OGRE_BINARY_DIR}/../EmscriptenDependencies"
"${OGRE_SOURCE_DIR}/../EmscriptenDependencies"
"${PROJECT_BINARY_DIR}/EmscriptenDependencies"
"${PROJECT_SOURCE_DIR}/EmscriptenDependencies"
"${PROJECT_BINARY_DIR}/../EmscriptenDependencies"
"${PROJECT_SOURCE_DIR}/../EmscriptenDependencies"
)
elseif(APPLE_IOS)
set(OGRE_DEP_SEARCH_PATH
${OGRE_DEPENDENCIES_DIR}
${ENV_OGRE_DEPENDENCIES_DIR}
"${OGRE_BINARY_DIR}/iOSDependencies"
"${OGRE_SOURCE_DIR}/iOSDependencies"
"${OGRE_BINARY_DIR}/../iOSDependencies"
"${OGRE_SOURCE_DIR}/../iOSDependencies"
"${PROJECT_BINARY_DIR}/iOSDependencies"
"${PROJECT_SOURCE_DIR}/iOSDependencies"
"${PROJECT_BINARY_DIR}/../iOSDependencies"
"${PROJECT_SOURCE_DIR}/../iOSDependencies"
)
elseif(OGRE_BUILD_PLATFORM_ANDROID)
set(OGRE_DEP_SEARCH_PATH
${OGRE_DEPENDENCIES_DIR}
${ENV_OGRE_DEPENDENCIES_DIR}
"${OGRE_BINARY_DIR}/AndroidDependencies"
"${OGRE_SOURCE_DIR}/AndroidDependencies"
"${OGRE_BINARY_DIR}/../AndroidDependencies"
"${OGRE_SOURCE_DIR}/../AndroidDependencies"
"${PROJECT_BINARY_DIR}/AndroidDependencies"
"${PROJECT_SOURCE_DIR}/AndroidDependencies"
"${PROJECT_BINARY_DIR}/../AndroidDependencies"
"${PROJECT_SOURCE_DIR}/../AndroidDependencies"
)
else()
set(OGRE_DEP_SEARCH_PATH
${OGRE_DEPENDENCIES_DIR}
${ENV_OGRE_DEPENDENCIES_DIR}
"${OGRE_BINARY_DIR}/Dependencies"
"${OGRE_SOURCE_DIR}/Dependencies"
"${OGRE_BINARY_DIR}/../Dependencies"
"${OGRE_SOURCE_DIR}/../Dependencies"
"${PROJECT_BINARY_DIR}/Dependencies"
"${PROJECT_SOURCE_DIR}/Dependencies"
"${PROJECT_BINARY_DIR}/../Dependencies"
"${PROJECT_SOURCE_DIR}/../Dependencies"
)
endif()

Expand Down Expand Up @@ -106,29 +106,29 @@ if(OGRE_BUILD_DEPENDENCIES AND NOT EXISTS ${OGREDEPS_PATH})
message(STATUS "Building zlib")
file(DOWNLOAD
http://zlib.net/zlib-1.2.11.tar.gz
${OGRE_BINARY_DIR}/zlib-1.2.11.tar.gz
${PROJECT_BINARY_DIR}/zlib-1.2.11.tar.gz
EXPECTED_MD5 1c9f62f0778697a09d36121ead88e08e)
execute_process(COMMAND ${CMAKE_COMMAND}
-E tar xf zlib-1.2.11.tar.gz WORKING_DIRECTORY ${OGRE_BINARY_DIR})
-E tar xf zlib-1.2.11.tar.gz WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${OGREDEPS_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${OGREDEPS_SHARED}
-G ${CMAKE_GENERATOR}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
${CROSS}
${OGRE_BINARY_DIR}/zlib-1.2.11
WORKING_DIRECTORY ${OGRE_BINARY_DIR}/zlib-1.2.11)
${PROJECT_BINARY_DIR}/zlib-1.2.11
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/zlib-1.2.11)
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${OGRE_BINARY_DIR}/zlib-1.2.11 ${BUILD_COMMAND_OPTS})
--build ${PROJECT_BINARY_DIR}/zlib-1.2.11 ${BUILD_COMMAND_OPTS})
endif()

message(STATUS "Building ZZIPlib")
file(DOWNLOAD
https://github.com/paroj/ZZIPlib/archive/master.tar.gz
${OGRE_BINARY_DIR}/ZZIPlib-master.tar.gz)
${PROJECT_BINARY_DIR}/ZZIPlib-master.tar.gz)
execute_process(COMMAND ${CMAKE_COMMAND}
-E tar xf ZZIPlib-master.tar.gz WORKING_DIRECTORY ${OGRE_BINARY_DIR})
-E tar xf ZZIPlib-master.tar.gz WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${OGREDEPS_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
Expand All @@ -137,58 +137,58 @@ if(OGRE_BUILD_DEPENDENCIES AND NOT EXISTS ${OGREDEPS_PATH})
-G ${CMAKE_GENERATOR}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
${CROSS}
${OGRE_BINARY_DIR}/ZZIPlib-master
WORKING_DIRECTORY ${OGRE_BINARY_DIR}/ZZIPlib-master)
${PROJECT_BINARY_DIR}/ZZIPlib-master
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/ZZIPlib-master)
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${OGRE_BINARY_DIR}/ZZIPlib-master ${BUILD_COMMAND_OPTS})
--build ${PROJECT_BINARY_DIR}/ZZIPlib-master ${BUILD_COMMAND_OPTS})

message(STATUS "Building freetype")
file(DOWNLOAD
https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
${OGRE_BINARY_DIR}/freetype-2.9.tar.gz)
${PROJECT_BINARY_DIR}/freetype-2.9.tar.gz)
execute_process(COMMAND ${CMAKE_COMMAND}
-E tar xf freetype-2.9.tar.gz WORKING_DIRECTORY ${OGRE_BINARY_DIR})
-E tar xf freetype-2.9.tar.gz WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
# patch toolchain for iOS
execute_process(COMMAND ${CMAKE_COMMAND} -E copy
${OGRE_SOURCE_DIR}/CMake/toolchain/ios.toolchain.xcode.cmake
${PROJECT_SOURCE_DIR}/CMake/toolchain/ios.toolchain.xcode.cmake
freetype-2.9/builds/cmake/iOS.cmake
WORKING_DIRECTORY ${OGRE_BINARY_DIR})
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${OGREDEPS_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${OGREDEPS_SHARED}
-DWITH_PNG=OFF
-DWITH_BZip2=OFF # tries to use it on iOS otherwise
# workaround for broken iOS toolchain in freetype
-DPROJECT_SOURCE_DIR=${OGRE_BINARY_DIR}/freetype-2.9
-DPROJECT_SOURCE_DIR=${PROJECT_BINARY_DIR}/freetype-2.9
${CROSS}
-G ${CMAKE_GENERATOR}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
${OGRE_BINARY_DIR}/freetype-2.9
WORKING_DIRECTORY ${OGRE_BINARY_DIR}/freetype-2.9/objs)
${PROJECT_BINARY_DIR}/freetype-2.9
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/freetype-2.9/objs)
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${OGRE_BINARY_DIR}/freetype-2.9/objs ${BUILD_COMMAND_OPTS})
--build ${PROJECT_BINARY_DIR}/freetype-2.9/objs ${BUILD_COMMAND_OPTS})

if(MSVC OR MINGW) # other platforms dont need this
message(STATUS "Building SDL2")
file(DOWNLOAD
https://libsdl.org/release/SDL2-2.0.8.tar.gz
${OGRE_BINARY_DIR}/SDL2-2.0.8.tar.gz)
${PROJECT_BINARY_DIR}/SDL2-2.0.8.tar.gz)
execute_process(COMMAND ${CMAKE_COMMAND}
-E tar xf SDL2-2.0.8.tar.gz WORKING_DIRECTORY ${OGRE_BINARY_DIR})
-E tar xf SDL2-2.0.8.tar.gz WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND}
-E make_directory ${OGRE_BINARY_DIR}/SDL2-build)
-E make_directory ${PROJECT_BINARY_DIR}/SDL2-build)
execute_process(COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${OGREDEPS_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DSDL_STATIC=FALSE
-G ${CMAKE_GENERATOR}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
${CROSS}
${OGRE_BINARY_DIR}/SDL2-2.0.8
WORKING_DIRECTORY ${OGRE_BINARY_DIR}/SDL2-build)
${PROJECT_BINARY_DIR}/SDL2-2.0.8
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/SDL2-build)
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${OGRE_BINARY_DIR}/SDL2-build ${BUILD_COMMAND_OPTS})
--build ${PROJECT_BINARY_DIR}/SDL2-build ${BUILD_COMMAND_OPTS})
endif()
endif()

Expand Down Expand Up @@ -311,9 +311,9 @@ macro_log_feature(Softimage_FOUND "Softimage" "Softimage SDK needed for building
# setting everything up, including overriding any of the above
# findings.
set(OGREDEPS_RUNTIME_OUTPUT ${OGRE_RUNTIME_OUTPUT})
if (EXISTS "${OGRE_SOURCE_DIR}/Dependencies/CMakeLists.txt")
if (EXISTS "${PROJECT_SOURCE_DIR}/Dependencies/CMakeLists.txt")
add_subdirectory(Dependencies)
elseif (EXISTS "${OGRE_SOURCE_DIR}/ogredeps/CMakeLists.txt")
elseif (EXISTS "${PROJECT_SOURCE_DIR}/ogredeps/CMakeLists.txt")
add_subdirectory(ogredeps)
endif ()

Expand Down
Loading

0 comments on commit 98563cb

Please sign in to comment.