| 1 |
#CMAKE_ARGV0 = /path/to/cmake |
| 2 |
#CMAKE_ARGV1 = -P |
| 3 |
#CMAKE_ARGV2 = path/to/this/file |
| 4 |
#CMAKE_ARGV3 = binder |
| 5 |
#CMAKE_ARGV4 = ali |
| 6 |
|
| 7 |
if(NOT CMAKE_ARGV3) |
| 8 |
message(FATAL_ERROR "binder not set") |
| 9 |
endif(NOT CMAKE_ARGV3) |
| 10 |
|
| 11 |
string(REPLACE ".o" ".ali" ALI ${CMAKE_ARGV4}) |
| 12 |
|
| 13 |
set (REACHED_FLAGS FALSE) |
| 14 |
#iterate over additional objects, only the main one is needed |
| 15 |
foreach(arg RANGE 5 ${CMAKE_ARGC}) |
| 16 |
if(CMAKE_ARGV${arg} STREQUAL FLAGS) |
| 17 |
set(REACHED_FLAGS TRUE) |
| 18 |
continue() |
| 19 |
endif(CMAKE_ARGV${arg} STREQUAL FLAGS) |
| 20 |
|
| 21 |
string(SUBSTRING "${CMAKE_ARGV${arg}}" 0 2 start) |
| 22 |
|
| 23 |
if(start STREQUAL "-O") |
| 24 |
continue() |
| 25 |
endif(start STREQUAL "-O") |
| 26 |
|
| 27 |
if(REACHED_FLAGS) |
| 28 |
list(APPEND FLAGS ${CMAKE_ARGV${arg}}) |
| 29 |
endif(REACHED_FLAGS) |
| 30 |
endforeach(arg RANGE 5 CMAKE_ARGC) |
| 31 |
|
| 32 |
#first see if there is a main function |
| 33 |
execute_process(COMMAND ${CMAKE_ARGV3} bind ${ALI} ${FLAGS} |
| 34 |
RESULT_VARIABLE MAIN_RESULT |
| 35 |
OUTPUT_VARIABLE dont_care |
| 36 |
ERROR_VARIABLE ERROR) |
| 37 |
|
| 38 |
if(MAIN_RESULT) |
| 39 |
execute_process(COMMAND ${CMAKE_ARGV3} bind -n ${ALI} ${FLAGS} |
| 40 |
RESULT_VARIABLE RESULT |
| 41 |
OUTPUT_VARIABLE dont_care |
| 42 |
ERROR_VARIABLE ERROR) |
| 43 |
endif(MAIN_RESULT) |
| 44 |
|
| 45 |
if(RESULT) |
| 46 |
message(FATAL_ERROR ${RESULT} ${ERROR}) |
| 47 |
endif(RESULT) |