Skip to content

Commit

Permalink
Update CMakeLists.txt to handle file names with spaces and quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
fenilgmehta committed Aug 11, 2019
1 parent a67355e commit 0cafd7f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
25 changes: 18 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB sourceFILES *.cpp *.c)
FOREACH (sourceFile ${sourceFILES})
#get_filename_component(sourceFile_Path ${sourceFile} PATH)
get_filename_component(sourceFile_Name ${sourceFile} NAME)
get_filename_component(sourceFile_Path ${sourceFile} PATH)
MESSAGE(STATUS "Process file, path: ${sourceFile}")

MESSAGE(STATUS "Process file, name: ${sourceFile_Name}")
#MESSAGE(STATUS "Process file, path: ${sourceFile}")
get_filename_component(sourceFile_Name ${sourceFile} NAME)
string(REPLACE " " "_" sourceFile_Name ${sourceFile_Name})
string(REPLACE "'" "" sourceFile_Name ${sourceFile_Name})
string(REPLACE "\"" "" sourceFile_Name ${sourceFile_Name})
MESSAGE(STATUS "Process file, name: \"${sourceFile_Name}\"")

add_executable("${sourceFile_Name}" ${sourceFile})
add_executable("${sourceFile_Name}" "${sourceFile}")
endforeach (sourceFile)


file(GLOB sourceFILES *.hpp *.h)
FOREACH (sourceFile ${sourceFILES})
get_filename_component(sourceFile_Path ${sourceFile} PATH)
MESSAGE(STATUS "Process file, path: ${sourceFile}")

get_filename_component(sourceFile_Name ${sourceFile} NAME)
MESSAGE(STATUS "Process file, name: ${sourceFile_Name}")
add_executable("${sourceFile_Name}" ${sourceFile})
string(REPLACE " " "_" sourceFile_Name ${sourceFile_Name})
string(REPLACE "'" "" sourceFile_Name ${sourceFile_Name})
string(REPLACE "\"" "" sourceFile_Name ${sourceFile_Name})
MESSAGE(STATUS "Process file, name: \"${sourceFile_Name}\"")

add_executable("${sourceFile_Name}" "${sourceFile}")
set_target_properties(${sourceFile_Name} PROPERTIES LINKER_LANGUAGE CXX)
endforeach (sourceFile)

Expand Down
29 changes: 24 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,34 @@ project(project_Sorting C CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB sourceFILES *.cpp *.c *.hpp)
file(GLOB sourceFILES *.cpp *.c)
FOREACH (sourceFile ${sourceFILES})
#get_filename_component(sourceFile_Path ${sourceFile} PATH)
get_filename_component(sourceFile_Path ${sourceFile} PATH)
MESSAGE(STATUS "Process file, path: ${sourceFile}")

get_filename_component(sourceFile_Name ${sourceFile} NAME)
string(REPLACE " " "_" sourceFile_Name ${sourceFile_Name})
string(REPLACE "'" "" sourceFile_Name ${sourceFile_Name})
string(REPLACE "\"" "" sourceFile_Name ${sourceFile_Name})
MESSAGE(STATUS "Process file, name: \"${sourceFile_Name}\"")

add_executable("${sourceFile_Name}" "${sourceFile}")
endforeach (sourceFile)


MESSAGE(STATUS "Process file, name: ${sourceFile_Name}")
#MESSAGE(STATUS "Process file, path: ${sourceFile}")
file(GLOB sourceFILES *.hpp *.h)
FOREACH (sourceFile ${sourceFILES})
get_filename_component(sourceFile_Path ${sourceFile} PATH)
MESSAGE(STATUS "Process file, path: ${sourceFile}")

get_filename_component(sourceFile_Name ${sourceFile} NAME)
string(REPLACE " " "_" sourceFile_Name ${sourceFile_Name})
string(REPLACE "'" "" sourceFile_Name ${sourceFile_Name})
string(REPLACE "\"" "" sourceFile_Name ${sourceFile_Name})
MESSAGE(STATUS "Process file, name: \"${sourceFile_Name}\"")

add_executable("${sourceFile_Name}" ${sourceFile})
add_executable("${sourceFile_Name}" "${sourceFile}")
set_target_properties(${sourceFile_Name} PROPERTIES LINKER_LANGUAGE CXX)
endforeach (sourceFile)

#add_executable(raw_data_generator_integer.cpp raw_data_generator_integer.cpp)
Expand Down

0 comments on commit 0cafd7f

Please sign in to comment.