Skip to content

Commit

Permalink
lint CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli committed Jun 4, 2018
1 parent 765ab40 commit 13b1ad9
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 43 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ make_script: &make_script
sudo: required
matrix:
include:
# Linting
- os: linux
dist: trusty
env: LINTING
install:
- sudo pip install cmakelint==1.3.4.1
script:
- cmakelint --filter=-linelength $(find . -name 'CMakeLists.txt' -print)
# Linux 64-bit
- haxe: development
os: linux
Expand Down
54 changes: 32 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)

cmake_policy(SET CMP0042 NEW)

if (WIN32)
if(WIN32)
project(hashlink C CXX) # C++ required for directx
else()
project(hashlink C)
Expand All @@ -13,17 +13,20 @@ include(FindPkgConfig)
include(CTest)

# force Unicode over Multi-byte
if (MSVC)
if(MSVC)
add_definitions(-DUNICODE -D_UNICODE)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/other/cmake ${CMAKE_MODULE_PATH})
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/other/cmake
)

if (CMAKE_VERSION VERSION_LESS "3.1")
set (CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
else ()
set (CMAKE_C_STANDARD 11)
endif ()
if(CMAKE_VERSION VERSION_LESS "3.1")
set(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
endif()

# put output in "bin"

Expand All @@ -33,13 +36,12 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIR})

# avoid the extra "Debug", "Release" directories
# http://stackoverflow.com/questions/7747857/in-cmake-how-do-i-work-around-the-debug-and-release-directories-visual-studio-2
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
endforeach()

set(HL_VERSION_MAJOR 1)
set(HL_VERSION_MINOR 6)
Expand Down Expand Up @@ -77,13 +79,13 @@ file(GLOB std_srcs
src/std/process.c
)

if (ANDROID)
if(ANDROID)
list(APPEND std_srcs
src/std/sys_android.c
)
endif()

if (IOS_PLATFORM)
if(IOS_PLATFORM)
list(APPEND std_srcs
src/std/sys_ios.m
)
Expand Down Expand Up @@ -141,7 +143,7 @@ else()
target_link_libraries(libhl m dl pthread)
endif()

if (BUILD_TESTING)
if(BUILD_TESTING)

#####################
# hello.hl
Expand All @@ -152,7 +154,9 @@ if (BUILD_TESTING)
)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.hl
COMMAND ${HAXE_COMPILER} -hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.hl -cp ${CMAKE_SOURCE_DIR}/other/tests -main HelloWorld
COMMAND ${HAXE_COMPILER}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.hl
-cp ${CMAKE_SOURCE_DIR}/other/tests -main HelloWorld
)
add_custom_target(hello.hl ALL
DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.hl
Expand All @@ -162,7 +166,9 @@ if (BUILD_TESTING)
# hello.c

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.c
COMMAND ${HAXE_COMPILER} -hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.c -cp ${CMAKE_SOURCE_DIR}/other/tests -main HelloWorld
COMMAND ${HAXE_COMPILER}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.c
-cp ${CMAKE_SOURCE_DIR}/other/tests -main HelloWorld
)
add_executable(hello
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.c
Expand Down Expand Up @@ -207,10 +213,10 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${HL_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${HL_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${HL_VERSION_PATCH})

if (WIN32)
set(CPACK_GENERATOR "ZIP")
if(WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
set(CPACK_GENERATOR "TGZ")
endif()

set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
Expand All @@ -231,16 +237,20 @@ install(
)


if (NOT DEFINED ENV{APPVEYOR_REPO_TAG_NAME} AND DEFINED ENV{APPVEYOR_REPO_COMMIT})
if(
NOT DEFINED ENV{APPVEYOR_REPO_TAG_NAME}
AND
DEFINED ENV{APPVEYOR_REPO_COMMIT}
)
string(SUBSTRING $ENV{APPVEYOR_REPO_COMMIT} 0 7 short_commit)
endif()

if (NOT DEFINED ENV{TRAVIS_TAG} AND DEFINED ENV{TRAVIS_COMMIT})
if(NOT DEFINED ENV{TRAVIS_TAG} AND DEFINED ENV{TRAVIS_COMMIT})
string(SUBSTRING $ENV{TRAVIS_COMMIT} 0 7 short_commit)
endif()

if (DEFINED short_commit)
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}+${short_commit}")
if(DEFINED short_commit)
set(CPACK_PACKAGE_VERSION "${HL_VERSION}+${short_commit}")
endif()


Expand Down
4 changes: 2 additions & 2 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ if(WIN32)
endif()

option(WITH_FMT "Build fmt.hdll." ON)
if (WITH_FMT)
if(WITH_FMT)
add_subdirectory(fmt)
endif()

# add_subdirectory(mesa)

if(WIN32)
option(WITH_OPENAL "Build openal.hdll." ON)
if (WITH_OPENAL)
if(WITH_OPENAL)
add_subdirectory(openal)
endif()
endif()
Expand Down
24 changes: 12 additions & 12 deletions libs/directx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
find_package(DirectX)

add_library(directx.hdll SHARED
directx.cpp
gamecontroller.c
window.c
directx.cpp
gamecontroller.c
window.c
)

set_as_hdll(directx)

target_link_libraries(directx.hdll
libhl
d3d11
dxgi
d3dcompiler
xinput9_1_0
dinput8
libhl
d3d11
dxgi
d3dcompiler
xinput9_1_0
dinput8
)

install(
TARGETS
directx.hdll
DESTINATION ${HDLL_DESTINATION}
TARGETS
directx.hdll
DESTINATION ${HDLL_DESTINATION}
)
4 changes: 2 additions & 2 deletions libs/fmt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ else()
find_package(PNG REQUIRED)

find_package(TurboJPEG QUIET)
if (NOT TurboJPEG_FOUND)
if(NOT TurboJPEG_FOUND)
pkg_check_modules(TurboJPEG REQUIRED libjpeg)
endif()

find_package(OggVorbis QUIET)
if (NOT OGGVORBIS_FOUND)
if(NOT OGGVORBIS_FOUND)
pkg_check_modules(OGGVORBIS REQUIRED vorbis vorbisenc vorbisfile)
endif()

Expand Down
4 changes: 2 additions & 2 deletions libs/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (WIN32)
if(WIN32)
set(SDL2_PATH ${INCLUDES_BASE_DIR}/sdl)
endif()
find_package(SDL2 REQUIRED)
Expand All @@ -25,7 +25,7 @@ if(WIN32)
)
endif()

if (APPLE)
if(APPLE)
find_package(OPENGL REQUIRED)
target_include_directories(sdl.hdll
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(ui.hdll SHARED ui_stub.c)

if (WIN32)
if(WIN32)
set_target_properties(ui.hdll PROPERTIES SOURCES ui_win.c)
endif()

Expand Down
4 changes: 2 additions & 2 deletions libs/uv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_library(uv.hdll SHARED
uv.c
)

if (WIN32)
if(WIN32)
target_sources(uv.hdll
PRIVATE
${INCLUDES_BASE_DIR}/libuv/src/fs-poll.c
Expand Down Expand Up @@ -45,7 +45,7 @@ set_as_hdll(uv)
target_link_libraries(uv.hdll
libhl
)
if (WIN32)
if(WIN32)
target_include_directories(uv.hdll
PRIVATE
${INCLUDES_BASE_DIR}/libuv/include
Expand Down

0 comments on commit 13b1ad9

Please sign in to comment.