Skip to content

Commit

Permalink
Consistent style for CMake scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCycoONE committed Jan 11, 2018
1 parent 1ce778c commit 6edc192
Show file tree
Hide file tree
Showing 16 changed files with 465 additions and 463 deletions.
68 changes: 33 additions & 35 deletions AnimView/CMakeLists.txt
@@ -1,9 +1,9 @@
# Project Declaration
PROJECT(AnimView)
project(AnimView)

# Generate source files list
# Note: do not use generic includes (*.cpp and such) this will break things with cmake
SET(animview_source_files
set(animview_source_files
app.cpp
frmMain.cpp
frmSprites.cpp
Expand All @@ -24,8 +24,7 @@ SET(animview_source_files
)

# Declaration of the executable
IF(APPLE)

if(APPLE)
set(corsixth_icon_file ${CMAKE_SOURCE_DIR}/AnimView/Icon.icns)
set_source_files_properties(
${corsixth_icon_file}
Expand All @@ -43,57 +42,56 @@ IF(APPLE)

set_target_properties(AnimView PROPERTIES LINK_FLAGS_MINSIZEREL "-dead_strip")
set_target_properties(AnimView PROPERTIES XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks")

ELSE()
else()
add_executable(
AnimView
WIN32 # This prevents the dos console showing up
${animview_source_files}
)
ENDIF()
endif()

# Finding libraries
## Finding libraries

# Find WxWidgets
SET(wxWidgets_USE_LIBS core base) # optionally: more than wx std libs
FIND_PACKAGE(wxWidgets REQUIRED)
IF(wxWidgets_FOUND)
LINK_LIBRARIES(${wxWidgets_LIBRARIES})
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
INCLUDE(${wxWidgets_USE_FILE})
TARGET_LINK_LIBRARIES(AnimView ${wxWidgets_LIBRARIES})
set(wxWidgets_USE_LIBS core base) # optionally: more than wx std libs
find_package(wxWidgets REQUIRED)
if(wxWidgets_FOUND)
link_libraries(${wxWidgets_LIBRARIES})
include_directories(${wxWidgets_INCLUDE_DIRS})
include(${wxWidgets_USE_FILE})
target_link_libraries(AnimView ${wxWidgets_LIBRARIES})
message(" wxWidgets found")
ELSE(wxWidgets_FOUND)
else()
message(FATAL_ERROR "error: wxWdigets library not found, it is required to build")
message("Make sure the path is correctly defined or set the environment variable WXWIN to the correct location")
ENDIF(wxWidgets_FOUND)
endif()

# Basic platform dependant stuff
IF(UNIX)
IF(APPLE)
if(UNIX)
if(APPLE)
# fruit goes here
ELSE(APPLE)
else()
# regular unix/linux
ENDIF(APPLE)
ELSE(UNIX)
IF(WIN32)
endif()
else()
if(WIN32)
# Win32 specific
IF(MSVC)
if(MSVC)
# We want to bind against the very latest versions of the MSVC runtimes
add_definitions(/D "_BIND_TO_CURRENT_VCLIBS_VERSION=1")
ELSE(MSVC)
IF(MSYS)
else()
if(MSYS)
# MSYS stuff
ELSE(MSYS)
else()
# What's left? MINGW? CYGWIN? BORLAND?
ENDIF(MSYS)
ENDIF(MSVC)
ELSE(WIN32)
endif()
endif()
else()
# other OS (not UNIX, not 32/64 bit Windows)
ENDIF(WIN32)
ENDIF(UNIX)
endif()
endif()

IF(APPLE)
if(APPLE)
install(TARGETS AnimView BUNDLE DESTINATION .)

# Fix the OS X bundle to include required libraries (create a redistributable app)
Expand All @@ -102,7 +100,7 @@ IF(APPLE)
SET(BU_CHMOD_BUNDLE_ITEMS ON)
FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/AnimView.app \"\" \"\")
")
ELSE()
else()
install(TARGETS AnimView RUNTIME DESTINATION AnimView)
install(FILES LICENSE.txt DESTINATION AnimView )
ENDIF()
endif()
24 changes: 12 additions & 12 deletions CMake/CMakeFFmpegLibavMacros.cmake
Expand Up @@ -11,12 +11,12 @@
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
#
macro(set_component_found _component )
if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
# message(STATUS " - ${_component} found.")
set(${_component}_FOUND TRUE)
else ()
else()
# message(STATUS " - ${_component} not found.")
endif ()
endif()
endmacro()

#
Expand All @@ -27,7 +27,6 @@ endmacro()
# component's version and sets *_VERSION_STRING.
#
macro(find_component _component _library _header _version)

find_path(${_component}_INCLUDE_DIRS ${_header}
PATH_SUFFIXES
ffmpeg
Expand All @@ -36,12 +35,12 @@ macro(find_component _component _library _header _version)
)

find_library(${_component}_LIBRARIES
NAMES ${_library}
PATH_SUFFIXES
lib
NAMES ${_library}
PATH_SUFFIXES
lib
)

if (${_component}_INCLUDE_DIRS AND EXISTS "${${_component}_INCLUDE_DIRS}/${_version}")
if(${_component}_INCLUDE_DIRS AND EXISTS "${${_component}_INCLUDE_DIRS}/${_version}")
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_MAJOR_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MAJOR[ \t]+[0-9]+$")
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_MINOR_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MINOR[ \t]+[0-9]+$")
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_PATCH_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MICRO[ \t]+[0-9]+$")
Expand All @@ -55,11 +54,12 @@ macro(find_component _component _library _header _version)
unset(${_component}_VERSION_MAJOR)
unset(${_component}_VERSION_MINOR)
unset(${_component}_VERSION_PATCH)
endif ()
endif()

find_package_handle_standard_args(${_component}
REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS
VERSION_VAR ${_component}_VERSION_STRING)
REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS
VERSION_VAR ${_component}_VERSION_STRING
)

set_component_found(${_component})

endmacro()
18 changes: 12 additions & 6 deletions CMake/CopyVcpkgLua.cmake
Expand Up @@ -2,28 +2,34 @@
add_custom_command(TARGET CorsixTH POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${VCPKG_INSTALLED_PATH}/share/lua"
$<TARGET_FILE_DIR:CorsixTH>)
$<TARGET_FILE_DIR:CorsixTH>
)

add_custom_command(TARGET CorsixTH POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove
$<TARGET_FILE_DIR:CorsixTH>/COPYRIGHT)
$<TARGET_FILE_DIR:CorsixTH>/COPYRIGHT
)

add_custom_command(TARGET CorsixTH POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/lfs.dll"
$<TARGET_FILE_DIR:CorsixTH>/lfs.dll)
$<TARGET_FILE_DIR:CorsixTH>/lfs.dll
)

add_custom_command(TARGET CorsixTH POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/lpeg.dll"
$<TARGET_FILE_DIR:CorsixTH>/lpeg.dll)
$<TARGET_FILE_DIR:CorsixTH>/lpeg.dll
)

add_custom_command(TARGET CorsixTH POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/mime/core.dll"
$<TARGET_FILE_DIR:CorsixTH>/mime/core.dll)
$<TARGET_FILE_DIR:CorsixTH>/mime/core.dll
)

add_custom_command(TARGET CorsixTH POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/socket/core.dll"
$<TARGET_FILE_DIR:CorsixTH>/socket/core.dll)
$<TARGET_FILE_DIR:CorsixTH>/socket/core.dll
)
52 changes: 25 additions & 27 deletions CMake/FindDirectX.cmake
Expand Up @@ -36,7 +36,7 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
"C:/Program Files (x86)/Microsoft DirectX SDK*"
"C:/apps/Microsoft DirectX SDK*"
"C:/Program Files/Microsoft DirectX SDK*"
"$ENV{ProgramFiles}/Microsoft DirectX SDK*"
"$ENV{ProgramFiles}/Microsoft DirectX SDK*"
)

# Windows 8 SDK has custom layout
Expand All @@ -52,23 +52,22 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
# redo search if prefix path changed
clear_if_changed(DirectX_PREFIX_PATH
DirectX_LIBRARY
DirectX_INCLUDE_DIR
DirectX_INCLUDE_DIR
)

find_path(DirectX_INCLUDE_DIR NAMES d3d9.h HINTS ${DirectX_INC_SEARCH_PATH})
# dlls are in DirectX_ROOT_DIR/Developer Runtime/x64|x86
# lib files are in DirectX_ROOT_DIR/Lib/x64|x86
if(CMAKE_CL_64)
set(DirectX_LIBPATH_SUFFIX "x64")
else(CMAKE_CL_64)
else()
set(DirectX_LIBPATH_SUFFIX "x86")
endif(CMAKE_CL_64)
endif()
find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
find_library(DirectX_DXERR_LIBRARY NAMES DxErr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})


# look for dxgi (needed by both 10 and 11)
find_library(DirectX_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})

Expand All @@ -83,33 +82,32 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
)

mark_as_advanced(DirectX_D3DX9_LIBRARY DirectX_DXERR_LIBRARY DirectX_DXGUID_LIBRARY
DirectX_DXGI_LIBRARY DirectX_D3DCOMPILER_LIBRARY)
DirectX_DXGI_LIBRARY DirectX_D3DCOMPILER_LIBRARY
)


# look for D3D11 components
if (DirectX_FOUND)
if(DirectX_FOUND)
find_path(DirectX_D3D11_INCLUDE_DIR NAMES D3D11Shader.h HINTS ${DirectX_INC_SEARCH_PATH})
get_filename_component(DirectX_LIBRARY_DIR "${DirectX_LIBRARY}" PATH)
message(STATUS "DX lib dir: ${DirectX_LIBRARY_DIR}")
get_filename_component(DirectX_LIBRARY_DIR "${DirectX_LIBRARY}" PATH)
message(STATUS "DX lib dir: ${DirectX_LIBRARY_DIR}")
find_library(DirectX_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
find_library(DirectX_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
if (DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
set(DirectX_D3D11_FOUND TRUE)
set(DirectX_D3D11_INCLUDE_DIR ${DirectX_D3D11_INCLUDE_DIR})
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES}
${DirectX_D3D11_LIBRARY}
${DirectX_DXGI_LIBRARY}
if(DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
set(DirectX_D3D11_FOUND TRUE)
set(DirectX_D3D11_INCLUDE_DIR ${DirectX_D3D11_INCLUDE_DIR})
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES}
${DirectX_D3D11_LIBRARY}
${DirectX_DXGI_LIBRARY}
${DirectX_DXGUID_LIBRARY}
${DirectX_D3DCOMPILER_LIBRARY}
)
endif ()
if (DirectX_D3DX11_LIBRARY)
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES} ${DirectX_D3DX11_LIBRARY})
endif ()
if (DirectX_DXERR_LIBRARY)
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES} ${DirectX_DXERR_LIBRARY})
endif ()
mark_as_advanced(DirectX_D3D11_INCLUDE_DIR DirectX_D3D11_LIBRARY DirectX_D3DX11_LIBRARY)
endif ()

endif(WIN32)
endif()
if(DirectX_D3DX11_LIBRARY)
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES} ${DirectX_D3DX11_LIBRARY})
endif()
if(DirectX_DXERR_LIBRARY)
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES} ${DirectX_DXERR_LIBRARY})
endif()
mark_as_advanced(DirectX_D3D11_INCLUDE_DIR DirectX_D3D11_LIBRARY DirectX_D3DX11_LIBRARY)
endif()
endif()
34 changes: 16 additions & 18 deletions CMake/FindFFmpeg.cmake
Expand Up @@ -33,12 +33,12 @@ include(FindPackageHandleStandardArgs)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFFmpegLibavMacros.cmake)

# The default components were taken from a survey over other FindFFMPEG.cmake files
if (NOT FFmpeg_FIND_COMPONENTS)
if(NOT FFmpeg_FIND_COMPONENTS)
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
endif ()
endif()

# Check for cached results. If there are skip the costly part.
if (NOT FFMPEG_LIBRARIES)
if(NOT FFMPEG_LIBRARIES)

# Check for all possible component.
find_component(AVCODEC avcodec libavcodec/avcodec.h libavcodec/version.h)
Expand All @@ -50,40 +50,38 @@ if (NOT FFMPEG_LIBRARIES)
find_component(SWRESAMPLE swresample libswresample/swresample.h libswresample/version.h)

# Check if the required components were found and add their stuff to the FFMPEG_* vars.
foreach (_component ${FFmpeg_FIND_COMPONENTS})
if (${_component}_FOUND)
foreach(_component ${FFmpeg_FIND_COMPONENTS})
if(${_component}_FOUND)
# message(STATUS "Required component ${_component} present.")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
else ()
else()
# message(STATUS "Required component ${_component} missing.")
endif ()
endforeach ()
endif()
endforeach()

# Build the include path with duplicates removed.
if (FFMPEG_INCLUDE_DIRS)
if(FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
endif ()
endif()

# cache the vars.
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)

mark_as_advanced(FFMPEG_INCLUDE_DIRS
FFMPEG_LIBRARIES)

endif ()
mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES)
endif()

# Now set the noncached _FOUND vars for the components.
foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE SWRESAMPLE)
foreach(_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE SWRESAMPLE)
set_component_found(${_component})
endforeach ()
endforeach()

# Compile the list of required vars
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
foreach (_component ${FFmpeg_FIND_COMPONENTS})
foreach(_component ${FFmpeg_FIND_COMPONENTS})
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
endforeach ()
endforeach()

# Give a nice error message if some of the required vars are missing.
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})

0 comments on commit 6edc192

Please sign in to comment.