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

cmake: use project-level variables, not top-level variables #214

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SET(SOVERSION 2)
SET(VERSION 2.1.0)

# Find Macros
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

INCLUDE(CMakeDependentOption)
INCLUDE(CheckCCompilerFlag)
Expand Down Expand Up @@ -272,11 +272,11 @@ IF (WIN32)
ENDIF (WIN32)

# ######### General setup ##########
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_SOURCE_DIR}/include")
FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include")
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_BINARY_DIR}/include")
INCLUDE_DIRECTORIES(BEFORE "${PROJECT_SOURCE_DIR}/include")
FILE(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include")
INCLUDE_DIRECTORIES(BEFORE "${PROJECT_BINARY_DIR}/include")
IF (NOT HAVE_STDINT_H) # AND NOT HAVE_INTTYPES_H
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_SOURCE_DIR}/include/stdint")
INCLUDE_DIRECTORIES(BEFORE "${PROJECT_SOURCE_DIR}/include/stdint")
ENDIF ()

IF (AMIGA OR AROS)
Expand All @@ -298,6 +298,6 @@ ELSE (APPLE)
ENDIF (APPLE)

# Setup up our config file
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/include/config.h.cmake" "${CMAKE_BINARY_DIR}/include/config.h")
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/include/config.h.cmake" "${PROJECT_BINARY_DIR}/include/config.h")

ADD_SUBDIRECTORY(src)
42 changes: 21 additions & 21 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ SET(wildmidi_executable_HDRS
)

# set our target paths
SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}")
SET(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}")

# set our library names
IF (WIN32 AND NOT CMAKE_COMPILER_IS_MINGW) # windows uses *.lib for both static and dynamic, workaround
Expand Down Expand Up @@ -135,29 +135,29 @@ IF (BUILD_SHARED_LIBS)
ENDIF (BUILD_SHARED_LIBS)

# Set our default and then look at the possible locations
SET(WILDMIDILIB "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.so")
SET(WILDMIDILIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
SET(WILDMIDILIB "${PROJECT_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.so")
SET(WILDMIDILIBSTATIC "${PROJECT_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")

# MS Visual Studio
IF (MSVC)
SET(WILDMIDILIB "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_DYN_NAME}.lib")
SET(WILDMIDILIBSTATIC "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_STATIC_NAME}.lib")
SET(WILDMIDILIB "${PROJECT_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_DYN_NAME}.lib")
SET(WILDMIDILIBSTATIC "${PROJECT_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_STATIC_NAME}.lib")
ENDIF (MSVC)

# MinGW or MinGW-w64
IF (CMAKE_COMPILER_IS_MINGW)
SET(WILDMIDILIB "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dll.a")
SET(WILDMIDIDLL "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dll")
SET(WILDMIDILIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
SET(WILDMIDILIB "${PROJECT_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dll.a")
SET(WILDMIDIDLL "${PROJECT_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dll")
SET(WILDMIDILIBSTATIC "${PROJECT_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
ENDIF (CMAKE_COMPILER_IS_MINGW)

# Apple's Xcode
IF (CMAKE_GENERATOR STREQUAL "Xcode")
SET(WILDMIDILIB "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_DYN_NAME}.dylib")
SET(WILDMIDILIBSTATIC "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_STATIC_NAME}.a")
SET(WILDMIDILIB "${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_DYN_NAME}.dylib")
SET(WILDMIDILIBSTATIC "${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_STATIC_NAME}.a")
ELSEIF (APPLE) # Apple's CLI default
SET(WILDMIDILIB "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dylib")
SET(WILDMIDILIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
SET(WILDMIDILIB "${PROJECT_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dylib")
SET(WILDMIDILIBSTATIC "${PROJECT_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
ENDIF (CMAKE_GENERATOR STREQUAL "Xcode")

# do we want the wildmidi player?
Expand Down Expand Up @@ -244,7 +244,7 @@ ENDIF ()
# prepare pkg-config file
SET(WILDMIDILIB_PREFIX "${CMAKE_INSTALL_PREFIX}")
SET(WILDMIDILIB_LIBDIR "${WILDMIDILIB_INSTALLDIR}")
CONFIGURE_FILE("wildmidi.pc.in" "${CMAKE_BINARY_DIR}/wildmidi.pc" @ONLY)
CONFIGURE_FILE("wildmidi.pc.in" "${PROJECT_BINARY_DIR}/wildmidi.pc" @ONLY)

# install target (*nix OSes)
IF (UNIX AND NOT APPLE)
Expand All @@ -269,18 +269,18 @@ IF (UNIX AND NOT APPLE)
ENDIF (WANT_DEVTEST)

# install pkg-config file
INSTALL(FILES ${CMAKE_BINARY_DIR}/wildmidi.pc DESTINATION "${WILDMIDILIB_INSTALLDIR}/pkgconfig")
INSTALL(FILES ${PROJECT_BINARY_DIR}/wildmidi.pc DESTINATION "${WILDMIDILIB_INSTALLDIR}/pkgconfig")

# install supporting man pages and headers
INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/wildmidi_lib.h DESTINATION include)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/docs/man/ DESTINATION share/man)
INSTALL(FILES ${PROJECT_SOURCE_DIR}/include/wildmidi_lib.h DESTINATION include)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/docs/man/ DESTINATION share/man)
ENDIF (UNIX AND NOT APPLE)

# install target (Windows: MinGW or MinGW-w64)
IF (WIN32 AND CMAKE_COMPILER_IS_MINGW)
IF ("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
MESSAGE("INSTALL PREFIX IS EMPTY")
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/wildmidi_lib" CACHE STRING "Install Prefix" FORCE)
SET(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/wildmidi_lib" CACHE STRING "Install Prefix" FORCE)
MESSAGE("INSTALL PREFIX NOW: ${CMAKE_INSTALL_PREFIX}")
ENDIF ("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
# install our libraries
Expand All @@ -304,11 +304,11 @@ IF (WIN32 AND CMAKE_COMPILER_IS_MINGW)
ENDIF (WANT_DEVTEST)

# install pkg-config file
INSTALL(FILES ${CMAKE_BINARY_DIR}/wildmidi.pc DESTINATION "${WILDMIDILIB_INSTALLDIR}/pkgconfig")
INSTALL(FILES ${PROJECT_BINARY_DIR}/wildmidi.pc DESTINATION "${WILDMIDILIB_INSTALLDIR}/pkgconfig")

# install supporting man pages and headers
INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/wildmidi_lib.h DESTINATION include)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/docs/man/ DESTINATION share/man)
INSTALL(FILES ${PROJECT_SOURCE_DIR}/include/wildmidi_lib.h DESTINATION include)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/docs/man/ DESTINATION share/man)
ENDIF (WIN32 AND CMAKE_COMPILER_IS_MINGW)

IF (WIN32 AND MSVC)
Expand Down