Skip to content

Commit

Permalink
Add support for distributing ccmake executable
Browse files Browse the repository at this point in the history
See #66
  • Loading branch information
jcfr committed Apr 29, 2020
1 parent 0987e15 commit 633f59b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,23 @@ set(CMAKE_EXE_LINKER_FLAGS \"-static-libstdc++ -static-libgcc -lrt\" CACHE STRIN
find_program(STRIP_EXECUTABLE strip)
if(STRIP_EXECUTABLE)

set(ccmake_executable "${CMakeProject_BINARY_DIR}/bin/ccmake")
set(cmake_executable "${CMakeProject_BINARY_DIR}/bin/cmake")
set(cpack_executable "${CMakeProject_BINARY_DIR}/bin/cpack")
set(ctest_executable "${CMakeProject_BINARY_DIR}/bin/ctest")

# Since the test for ccmake existence can not be done during the project
# configuration, stripping conditonally happens in a CMake script.
set(EXECUTABLE_TO_STRIP ${ccmake_executable})
configure_file(
${CMAKE_SOURCE_DIR}/scripts/strip_executable_if_exists.cmake.in
${CMAKE_BINARY_DIR}/scripts/strip_ccmake_executable_if_exists.cmake
)

ExternalProject_Add_Step(CMakeProject-build strip_executables
DEPENDEES build
COMMENT "Stripping CMake executables"
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/scripts/strip_ccmake_executable_if_exists.cmake
COMMAND ${STRIP_EXECUTABLE} ${cmake_executable}
COMMAND ${STRIP_EXECUTABLE} ${cpack_executable}
COMMAND ${STRIP_EXECUTABLE} ${ctest_executable}
Expand Down
10 changes: 9 additions & 1 deletion cmake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@


def _program(name, args):
return subprocess.call([os.path.join(CMAKE_BIN_DIR, name)] + args)
path = os.path.join(CMAKE_BIN_DIR, name)
if not os.path.exists(path):
return "%s is not available at %s" % (name, path)
else:
return subprocess.call([path] + args)


def ccmake():
raise SystemExit(_program('ccmake', sys.argv[1:]))


def cmake():
Expand Down
11 changes: 11 additions & 0 deletions scripts/strip_executable_if_exists.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

set(STRIP_EXECUTABLE "@STRIP_EXECUTABLE@")
set(EXECUTABLE_TO_STRIP "@EXECUTABLE_TO_STRIP@")

if(EXISTS ${EXECUTABLE_TO_STRIP})
execute_process(
COMMAND ${STRIP_EXECUTABLE} ${EXECUTABLE_TO_STRIP}
)
else()
message(STATUS "Skipping stripping of non existent executable: ${EXECUTABLE_TO_STRIP}")
endif()
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def parse_requirements(filename):

entry_points={
'console_scripts': [
'cmake=cmake:cmake', 'cpack=cmake:cpack', 'ctest=cmake:ctest'
'ccmake=cmake:ccmake',
'cmake=cmake:cmake',
'cpack=cmake:cpack',
'ctest=cmake:ctest'
]
},

Expand Down

0 comments on commit 633f59b

Please sign in to comment.