mirror of
				https://github.com/nicbarker/clay.git
				synced 2025-11-04 00:26:17 +00:00 
			
		
		
		
	CMake & MSVC fixes
This commit is contained in:
		
							parent
							
								
									51de072730
								
							
						
					
					
						commit
						8022610b3f
					
				| 
						 | 
					@ -4,6 +4,12 @@ project(sokol_video_demo C)
 | 
				
			||||||
include(FetchContent)
 | 
					include(FetchContent)
 | 
				
			||||||
set(FETCHCONTENT_QUIET FALSE)
 | 
					set(FETCHCONTENT_QUIET FALSE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Linux -pthread shenanigans
 | 
				
			||||||
 | 
					if (CMAKE_SYSTEM_NAME STREQUAL Linux)
 | 
				
			||||||
 | 
					    set(THREADS_PREFER_PTHREAD_FLAG ON)
 | 
				
			||||||
 | 
					    find_package(Threads REQUIRED)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FetchContent_Declare(
 | 
					FetchContent_Declare(
 | 
				
			||||||
    fontstash
 | 
					    fontstash
 | 
				
			||||||
    GIT_REPOSITORY "https://github.com/memononen/fontstash.git"
 | 
					    GIT_REPOSITORY "https://github.com/memononen/fontstash.git"
 | 
				
			||||||
| 
						 | 
					@ -42,18 +48,22 @@ else()
 | 
				
			||||||
    if (CMAKE_SYSTEM_NAME STREQUAL Linux)
 | 
					    if (CMAKE_SYSTEM_NAME STREQUAL Linux)
 | 
				
			||||||
        target_compile_definitions(sokol PRIVATE SOKOL_GLCORE=1)
 | 
					        target_compile_definitions(sokol PRIVATE SOKOL_GLCORE=1)
 | 
				
			||||||
        target_link_libraries(sokol INTERFACE X11 Xi Xcursor GL dl m)
 | 
					        target_link_libraries(sokol INTERFACE X11 Xi Xcursor GL dl m)
 | 
				
			||||||
 | 
					        target_link_libraries(sokol PUBLIC Threads::Threads)
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
target_include_directories(sokol INTERFACE ${sokol_SOURCE_DIR} ${fontstash_SOURCE_DIR}/src
 | 
					target_include_directories(sokol INTERFACE ${sokol_SOURCE_DIR} ${fontstash_SOURCE_DIR}/src
 | 
				
			||||||
                                 PRIVATE ${sokol_SOURCE_DIR} ${fontstash_SOURCE_DIR}/src)
 | 
					                                 PRIVATE ${sokol_SOURCE_DIR} ${fontstash_SOURCE_DIR}/src)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(MSVC)
 | 
					 | 
				
			||||||
    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /ENTRY:mainCRTStartup")
 | 
					 | 
				
			||||||
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /ENTRY:mainCRTStartup")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(sokol_video_demo main.c)
 | 
					
 | 
				
			||||||
 | 
					if(CMAKE_SYSTEM_NAME STREQUAL Windows)
 | 
				
			||||||
 | 
					    add_executable(sokol_video_demo WIN32 main.c)
 | 
				
			||||||
 | 
					    set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT sokol_video_demo)
 | 
				
			||||||
 | 
					else()
 | 
				
			||||||
 | 
					    add_executable(sokol_video_demo main.c)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
target_link_libraries(sokol_video_demo PUBLIC sokol)
 | 
					target_link_libraries(sokol_video_demo PUBLIC sokol)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_custom_command(
 | 
					add_custom_command(
 | 
				
			||||||
        TARGET sokol_video_demo POST_BUILD
 | 
					        TARGET sokol_video_demo POST_BUILD
 | 
				
			||||||
        COMMAND ${CMAKE_COMMAND} -E copy_directory
 | 
					        COMMAND ${CMAKE_COMMAND} -E copy_directory
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ static void init() {
 | 
				
			||||||
    sclay_setup();
 | 
					    sclay_setup();
 | 
				
			||||||
    uint64_t totalMemorySize = Clay_MinMemorySize();
 | 
					    uint64_t totalMemorySize = Clay_MinMemorySize();
 | 
				
			||||||
    Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize));
 | 
					    Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize));
 | 
				
			||||||
    Clay_Initialize(clayMemory, (Clay_Dimensions){ (float)sapp_width(), (float)sapp_height() }, (Clay_ErrorHandler){});
 | 
					    Clay_Initialize(clayMemory, (Clay_Dimensions){ (float)sapp_width(), (float)sapp_height() }, (Clay_ErrorHandler){0});
 | 
				
			||||||
    fonts[FONT_ID_BODY_16] = sclay_add_font("resources/Roboto-Regular.ttf");
 | 
					    fonts[FONT_ID_BODY_16] = sclay_add_font("resources/Roboto-Regular.ttf");
 | 
				
			||||||
    Clay_SetMeasureTextFunction(sclay_measure_text, &fonts);
 | 
					    Clay_SetMeasureTextFunction(sclay_measure_text, &fonts);
 | 
				
			||||||
    demoData = ClayVideoDemo_Initialize();
 | 
					    demoData = ClayVideoDemo_Initialize();
 | 
				
			||||||
| 
						 | 
					@ -75,5 +75,3 @@ sapp_desc sokol_main(int argc, char **argv) {
 | 
				
			||||||
        .logger.func = slog_func,
 | 
					        .logger.func = slog_func,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
int main();
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in a new issue