cmake_minimum_required( VERSION 2.8.6 ) project( bug13803 ) set( FileCount 0 ) set( Src ) while( ${FileCount} LESS 200 ) set( Filename "${CMAKE_BINARY_DIR}/File${FileCount}.cpp" ) file( WRITE "${Filename}" "namespace file${FileCount} { void foo() {} }\n" ) list( APPEND Src "${Filename}" ) message( "Created file ${Filename}" ) list( LENGTH Src FileCount ) endwhile() add_library( testlib STATIC ${Src} )