diff options
author | Chris Robinson <[email protected]> | 2017-08-26 02:21:50 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-08-26 02:21:50 -0700 |
commit | b1ff2a05af7e786e1d9f6b13d5338cd5178c067d (patch) | |
tree | fc20e8222c211c0544e527df0c158ec0f021cbab | |
parent | 561e95528f55be2837541239236281c4cd63d728 (diff) |
Always declare a native-tools build target
-rw-r--r-- | CMakeLists.txt | 72 | ||||
-rw-r--r-- | native-tools/CMakeLists.txt | 2 |
2 files changed, 40 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2204f97b..88fe4a36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1103,29 +1103,53 @@ ENDIF() # This is always available SET(BACKENDS "${BACKENDS} Null") -option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF) -if(ALSOFT_EMBED_HRTF_DATA) - SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/native-tools/") - SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools/") - FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}") - - SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}bin2h") - ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}" - COMMAND ${CMAKE_COMMAND} "${NATIVE_SRC_DIR}" - COMMAND ${CMAKE_COMMAND} --build . --config "Release" - WORKING_DIRECTORY "${NATIVE_BIN_DIR}" - DEPENDS "${NATIVE_SRC_DIR}CMakeLists.txt" "${NATIVE_SRC_DIR}bin2h.c" + +FIND_PACKAGE(Git) +IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") + # Get the current working branch and its latest abbreviated commit hash + ADD_CUSTOM_TARGET(build_version + ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} + -D LIB_VERSION=${LIB_VERSION} + -D SRC=${OpenAL_SOURCE_DIR}/version.h.in + -D DST=${OpenAL_BINARY_DIR}/version.h + -P ${OpenAL_SOURCE_DIR}/version.cmake + WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" VERBATIM ) +ELSE() + SET(GIT_BRANCH "UNKNOWN") + SET(GIT_COMMIT_HASH "unknown") + CONFIGURE_FILE( + "${OpenAL_SOURCE_DIR}/version.h.in" + "${OpenAL_BINARY_DIR}/version.h") +ENDIF() + +SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/native-tools/") +SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools/") +FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}") + +SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}bin2h") +ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}" + COMMAND ${CMAKE_COMMAND} "${NATIVE_SRC_DIR}" + COMMAND ${CMAKE_COMMAND} --build . --clean-first --config "Release" + WORKING_DIRECTORY "${NATIVE_BIN_DIR}" + DEPENDS "${NATIVE_SRC_DIR}CMakeLists.txt" "${NATIVE_SRC_DIR}bin2h.c" + VERBATIM +) +ADD_CUSTOM_TARGET(native-tools + DEPENDS "${BIN2H_COMMAND}" + VERBATIM +) +option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF) +if(ALSOFT_EMBED_HRTF_DATA) MACRO(make_hrtf_header FILENAME VARNAME) SET(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}") SET(outfile "${OpenAL_BINARY_DIR}/${FILENAME}.h") ADD_CUSTOM_COMMAND(OUTPUT "${outfile}" COMMAND "${BIN2H_COMMAND}" "${infile}" "${outfile}" ${VARNAME} - DEPENDS "${BIN2H_COMMAND}" "${infile}" - COMMENT "Generating ${FILENAME}.h" + DEPENDS native-tools "${infile}" VERBATIM ) @@ -1159,26 +1183,6 @@ ELSE() SET(LIBNAME "OpenAL32") ENDIF() -FIND_PACKAGE(Git) -IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") - # Get the current working branch and its latest abbreviated commit hash - ADD_CUSTOM_TARGET(build_version - ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} - -D LIB_VERSION=${LIB_VERSION} - -D SRC=${OpenAL_SOURCE_DIR}/version.h.in - -D DST=${OpenAL_BINARY_DIR}/version.h - -P ${OpenAL_SOURCE_DIR}/version.cmake - WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" - VERBATIM - ) -ELSE() - SET(GIT_BRANCH "UNKNOWN") - SET(GIT_COMMIT_HASH "unknown") - CONFIGURE_FILE( - "${OpenAL_SOURCE_DIR}/version.h.in" - "${OpenAL_BINARY_DIR}/version.h") -ENDIF() - # Needed for openal.pc.in SET(prefix ${CMAKE_INSTALL_PREFIX}) SET(exec_prefix "\${prefix}") diff --git a/native-tools/CMakeLists.txt b/native-tools/CMakeLists.txt index 4713dc56..bb8c677e 100644 --- a/native-tools/CMakeLists.txt +++ b/native-tools/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.0.2) + project(native-tools) + add_executable(bin2h bin2h.c) # Enforce no dressing for executable names, so the main script can find it set_target_properties(bin2h PROPERTIES OUTPUT_NAME bin2h) |