Skip to content

Commit 633f59b

Browse files
committed
Add support for distributing ccmake executable
See #66
1 parent 0987e15 commit 633f59b

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,23 @@ set(CMAKE_EXE_LINKER_FLAGS \"-static-libstdc++ -static-libgcc -lrt\" CACHE STRIN
260260
find_program(STRIP_EXECUTABLE strip)
261261
if(STRIP_EXECUTABLE)
262262

263+
set(ccmake_executable "${CMakeProject_BINARY_DIR}/bin/ccmake")
263264
set(cmake_executable "${CMakeProject_BINARY_DIR}/bin/cmake")
264265
set(cpack_executable "${CMakeProject_BINARY_DIR}/bin/cpack")
265266
set(ctest_executable "${CMakeProject_BINARY_DIR}/bin/ctest")
266267

268+
# Since the test for ccmake existence can not be done during the project
269+
# configuration, stripping conditonally happens in a CMake script.
270+
set(EXECUTABLE_TO_STRIP ${ccmake_executable})
271+
configure_file(
272+
${CMAKE_SOURCE_DIR}/scripts/strip_executable_if_exists.cmake.in
273+
${CMAKE_BINARY_DIR}/scripts/strip_ccmake_executable_if_exists.cmake
274+
)
275+
267276
ExternalProject_Add_Step(CMakeProject-build strip_executables
268277
DEPENDEES build
269278
COMMENT "Stripping CMake executables"
279+
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/scripts/strip_ccmake_executable_if_exists.cmake
270280
COMMAND ${STRIP_EXECUTABLE} ${cmake_executable}
271281
COMMAND ${STRIP_EXECUTABLE} ${cpack_executable}
272282
COMMAND ${STRIP_EXECUTABLE} ${ctest_executable}

cmake/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@
3939

4040

4141
def _program(name, args):
42-
return subprocess.call([os.path.join(CMAKE_BIN_DIR, name)] + args)
42+
path = os.path.join(CMAKE_BIN_DIR, name)
43+
if not os.path.exists(path):
44+
return "%s is not available at %s" % (name, path)
45+
else:
46+
return subprocess.call([path] + args)
47+
48+
49+
def ccmake():
50+
raise SystemExit(_program('ccmake', sys.argv[1:]))
4351

4452

4553
def cmake():
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
set(STRIP_EXECUTABLE "@STRIP_EXECUTABLE@")
3+
set(EXECUTABLE_TO_STRIP "@EXECUTABLE_TO_STRIP@")
4+
5+
if(EXISTS ${EXECUTABLE_TO_STRIP})
6+
execute_process(
7+
COMMAND ${STRIP_EXECUTABLE} ${EXECUTABLE_TO_STRIP}
8+
)
9+
else()
10+
message(STATUS "Skipping stripping of non existent executable: ${EXECUTABLE_TO_STRIP}")
11+
endif()

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def parse_requirements(filename):
4444

4545
entry_points={
4646
'console_scripts': [
47-
'cmake=cmake:cmake', 'cpack=cmake:cpack', 'ctest=cmake:ctest'
47+
'ccmake=cmake:ccmake',
48+
'cmake=cmake:cmake',
49+
'cpack=cmake:cpack',
50+
'ctest=cmake:ctest'
4851
]
4952
},
5053

0 commit comments

Comments
 (0)