Skip to content

Commit

Permalink
test new shell cmd logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 26, 2024
1 parent a94802a commit e54d9d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ endif()

# The shell command and prefix to use for running extra commands.
if(NOT DEFINED BASH_EXECUTABLE)
find_program(BASH_EXECUTABLE NAMES zsh bash REQUIRED HINTS /bin /usr/bin /usr/local/bin C:/msys64/usr/bin)
find_program(BASH_EXECUTABLE NAMES zsh bash REQUIRED HINTS C:/msys64/usr/bin /bin /usr/bin /usr/local/bin)
message(STATUS "Found bash: ${BASH_EXECUTABLE}")
endif()

Expand All @@ -49,15 +49,21 @@ if(NOT DEFINED SHELL_CMD_ARGS)
endif()

if(WIN32)
set(SHELL_CMD ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${BASH_EXECUTABLE} ${SHELL_CMD_ARGS})
# set(SHELL_CMD ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${BASH_EXECUTABLE} ${SHELL_CMD_ARGS})
# find_program(MSYS2_EXECUTABLE NAMES msys2_shell.cmd REQUIRED HINTS C:/msys64 D:/msys64)
find_file(MSYS2_EXECUTABLE NAMES msys2_shell.cmd REQUIRED HINTS D:/msys64 C:/msys64)
message(STATUS "Found MSYS2: ${MSYS2_EXECUTABLE}")
set(SHELL_CMD ${MSYS2_EXECUTABLE} -ucrt64 -defterm -here -no-start -shell bash -c)
else()
set(SHELL_CMD ${CMAKE_COMMAND} -E env PATH=$ENV{PATH} ${BASH_EXECUTABLE} ${SHELL_CMD_ARGS})
# set(SHELL_CMD ${CMAKE_COMMAND} -E env PATH=$ENV{PATH} ${BASH_EXECUTABLE} ${SHELL_CMD_ARGS})
set(SHELL_CMD ${BASH_EXECUTABLE} -c)
endif()

message(STATUS "Using shell command: ${SHELL_CMD}")

find_program(MAKE_EXECUTABLE
NAMES mingw32-make make gmake
NAMES make gmake # mingw32-make does not work for x264
HINTS C:/msys64/usr/bin /bin /usr/bin /usr/local/bin
NAMES_PER_DIR
DOC "GNU Make"
REQUIRED)
Expand Down
6 changes: 3 additions & 3 deletions cmake/ffmpeg/ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ endif()
set(WORKING_DIR ${FFMPEG_GENERATED_SRC_PATH})
UNIX_PATH(WORKING_DIR_UNIX ${WORKING_DIR})
add_custom_target(ffmpeg ALL
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ./configure \
COMMAND ${SHELL_CMD} "./configure \
--prefix=${CMAKE_CURRENT_BINARY_DIR_UNIX}/FFmpeg \
--cc=${CMAKE_C_COMPILER} \
--cxx=${CMAKE_CXX_COMPILER} \
--ar=${CMAKE_AR} \
--ranlib=${CMAKE_RANLIB} \
--optflags=${CMAKE_C_FLAGS} \
${FFMPEG_EXTRA_CONFIGURE}"
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ${MAKE_EXECUTABLE}"
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ${MAKE_EXECUTABLE} install"
COMMAND ${SHELL_CMD} "${MAKE_EXECUTABLE}"
COMMAND ${SHELL_CMD} "${MAKE_EXECUTABLE} install"
WORKING_DIRECTORY ${WORKING_DIR}
COMMENT "Configuring ffmpeg"
COMMAND_EXPAND_LISTS
Expand Down
5 changes: 3 additions & 2 deletions cmake/ffmpeg/nv_codec_headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ set(WORKING_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/nv-codec-headers
UNIX_PATH(WORKING_DIR_UNIX ${WORKING_DIR})
UNIX_PATH(DEST_DIR_UNIX ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(nv-codec-headers ALL
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ${MAKE_EXECUTABLE}"
COMMAND ${SHELL_CMD} "${MAKE_EXECUTABLE}"
# this will install the headers to the CMAKE_CURRENT_BINARY_DIR/usr/local
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && DESTDIR=${DEST_DIR_UNIX} ${MAKE_EXECUTABLE} install"
COMMAND ${SHELL_CMD} "DESTDIR=${DEST_DIR_UNIX} ${MAKE_EXECUTABLE} install"
WORKING_DIRECTORY ${WORKING_DIR}
COMMENT "Building nv-codec-headers"
COMMAND_EXPAND_LISTS
USES_TERMINAL
BYPRODUCTS "usr/local/include/ffnvcodec"
)
add_dependencies(${CMAKE_PROJECT_NAME} nv-codec-headers)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/usr/local/include/ffnvcodec"
Expand Down
7 changes: 4 additions & 3 deletions cmake/ffmpeg/x264.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ UNIX_PATH(CMAKE_CURRENT_BINARY_DIR_UNIX ${CMAKE_CURRENT_BINARY_DIR})
set(WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/x264)
UNIX_PATH(WORKING_DIR_UNIX ${WORKING_DIR})
add_custom_target(x264 ALL
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ./configure \
COMMAND ${SHELL_CMD} "./configure \
--prefix=${CMAKE_CURRENT_BINARY_DIR_UNIX}/x264 \
--disable-cli \
--enable-static \
${FFMPEG_X264_EXTRA_CONFIGURE}"
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ${MAKE_EXECUTABLE}"
COMMAND ${SHELL_CMD} "cd ${WORKING_DIR_UNIX} && ${MAKE_EXECUTABLE} install"
COMMAND ${SHELL_CMD} "${MAKE_EXECUTABLE} CC=${CMAKE_C_COMPILER}"
COMMAND ${SHELL_CMD} "${MAKE_EXECUTABLE} install"
WORKING_DIRECTORY ${WORKING_DIR}
COMMENT "Building x264"
COMMAND_EXPAND_LISTS
USES_TERMINAL
BYPRODUCTS "x264/lib/libx264.a" "x264/include/x264.h" "x264/include/x264_config.h"
)
add_dependencies(${CMAKE_PROJECT_NAME} x264)
set(X264_HEADER_FILES
Expand Down

0 comments on commit e54d9d4

Please sign in to comment.